0.0.4 • Published 10 years ago
rnhttpserver v0.0.4
react-native-httpserver
A http server for react native that serves files from a www
directory in your bundle.
Nice when you:
- want to load things into WebViews with 'http://' (instead of 'file://')
- want to use 'networked' images
Getting started
- Clone this repo into your node_modules directory
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-httpserver
and add the.xcodeproj
file - In the XCode project navigator, select your project. Add
libRNHTTPServer.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Click
RNHTTPServer.xcodeproj
in the project navigator, go to theBuild Settings
tab and make sureHeader Search Paths
contains both$(SRCROOT)/../../react-native/React
and$(SRCROOT)/../../../React
- mark both asrecursive
. - Create a folder called
www
in your project's top-level directory (usually next to your node_modules and index.js file), and put the files you want to access over http in there. - Add the
www
folder to Xcode (so it gets bundled with the app).
Usage
All you need is to require
the react-native-httpserver
module and then call the start
method, with a port.
var http = require('react-native-httpserver');
http.start("8999");
The toplevel URL then becomes http://127.0.0.1:8999/index.html
, also accessible as http.url()
.
Implementation
Based on MongooseDaemon and the mongoose server
Mongoose is cross platform, so an Android version should be possible.
Changelog
0.0.3 Published to npm
0.0.2 Replaced GCDWebServer with Mongoose
0.0.1 IPR
TODO
- Example project
- Android version
- Better docs