Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Httpd

Improve this doc

Embedded httpd for Cordova apps. Light weight HTTP server.

Repo: https://github.com/floatinghotpot/cordova-httpd

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-httpd
    $ npm install --save @ionic-native/httpd@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { Httpd, HttpdOptions } from '@ionic-native/httpd';

constructor(private httpd: Httpd) { }

...


let options: HttpdOptions = {
     www_root: 'httpd_root', // relative path to app's www directory
     port: 80,
     localhost_only: false
 };

this.httpd.startServer(options).subscribe((data) => {
 console.log('Server is live');
});

Instance Members

startServer(options)

Starts a web server.

Param Type Details
options HttpdOptions

Returns: Observable<string> Returns an Observable. Subscribe to receive the URL for your web server (if succeeded). Unsubscribe to stop the server.

getUrl()

Gets the URL of the running server

Returns: Promise<string> Returns a promise that resolves with the URL of the web server.

getLocalPath()

Get the local path of the running webserver

Returns: Promise<string> Returns a promise that resolves with the local path of the web server.

HttpdOptions

Param Type Details
www_root string

The public root directory for your web server. This path is relative to your app's www directory. Default is current directory.

(optional)
port number

The port number to use. Default is 8888

(optional)
localhost_only boolean

Setting this option to false will allow remote access to your web server (over any IP). Default is false.

(optional)

API

Native

General