Skip to content

Commit 3f9bb24

Browse files
committed
Updated readme
1 parent 5e702e4 commit 3f9bb24

File tree

2 files changed

+5415
-3
lines changed

2 files changed

+5415
-3
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import RNFS from 'react-native-fs';
6767
// create a path you want to write to
6868
let path = RNFS.DocumentDirectoryPath + '/www';
6969

70-
let server = new StaticServer(0, path);
70+
let server = new StaticServer(8080, path);
7171
```
7272

7373
#### Custom folder (iOS)
@@ -91,7 +91,7 @@ import RNFS from 'react-native-fs';
9191
// path where files will be served from (index.html here)
9292
let path = RNFS.MainBundlePath + '/www';
9393

94-
let server = new StaticServer(0, path);
94+
let server = new StaticServer(8080, path);
9595
```
9696

9797
If the server should only be accessible from within the app, set `localOnly` to `true`
@@ -107,9 +107,22 @@ let server = new StaticServer(8080, path, {localOnly : true });
107107

108108
```
109109

110+
If the server should not pause when the app is in the background, set `keepAlive` to `true`
111+
112+
```javascript
113+
let server = new StaticServer({keepAlive : true });
114+
```
115+
116+
Passing `0` as the port number will cause a random port to be assigned every time the server starts.
117+
It will reset to a new random port each time the server unpauses, so this should only be used with `keepAlive`.
118+
119+
```javascript
120+
let server = new StaticServer(0, {keepAlive : true });
121+
```
122+
110123
## Credits
111124

112-
* iOS server: [CocoaHTTPServer](https://github.com/robbiehanson/CocoaHTTPServer)
125+
* iOS server: [GCDWebServer](https://github.com/swisspol/GCDWebServer)
113126
* Android server: [NanoHttpd Webserver](https://github.com/NanoHttpd/nanohttpd)
114127

115128
Thanks to [CorHttpd](https://github.com/floatinghotpot/cordova-httpd) and [react-native-httpserver](https://gitlab.com/base.io/react-native-httpserver#README) for the basis of this library.

0 commit comments

Comments
 (0)