Httpd

Improve this doc

$ ionic plugin add https://github.com/floatinghotpot/cordova-httpd.git
$ npm install --save @ionic-native/httpd

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

Embedded httpd for Cordova apps. Light weight HTTP server.

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