File tree Expand file tree Collapse file tree 6 files changed +28
-33
lines changed
Expand file tree Collapse file tree 6 files changed +28
-33
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ cordova cli 8.0.0
33I have run:
44- cordova create app com.amanganiello30.angular angularDashFullStack
55- cordova platform add android --> 7.0.0
6- - cordova plugin add https://github.com/fullStackApp/ cordova-plugin-local-webserver
6+ - cordova plugin add cordova-plugin-httpd
77- cordova plugin add cordova-sqlite-storage
88- add GRADLE_HOME system environment variable with final /bin and insert into PATH
99- I copied the server-cordova.js file into www together the dist app builded and inject as javascript script in index.html
Original file line number Diff line number Diff line change 2323 <allow-intent href =" itms:*" />
2424 <allow-intent href =" itms-apps:*" />
2525 </platform >
26- <plugin name =" cordova-plugin-local-webserver " spec =" https://github.com/fullStackApp/cordova-plugin-local-webserver " />
26+ <plugin name =" cordova-plugin-httpd " spec =" ^0.9.3 " />
2727 <engine name =" android" spec =" ^7.0.0" />
2828</widget >
Original file line number Diff line number Diff line change 88 ],
99 "plugins" : {
1010 "cordova-plugin-whitelist" : {},
11- "cordova-plugin-local-webserver " : {}
11+ "cordova-plugin-httpd " : {}
1212 }
1313 },
1414 "dependencies" : {
1515 "cordova-android" : " ^7.0.0" ,
16- "cordova-plugin-local-webserver " : " git+https://github.com/fullStackApp/cordova-plugin-local-webserver.git " ,
16+ "cordova-plugin-httpd " : " ^0.9.3 " ,
1717 "cordova-plugin-whitelist" : " ^1.3.3"
1818 }
1919}
Original file line number Diff line number Diff line change 1010 "cordova-plugin-whitelist" : {
1111 "PACKAGE_NAME" : " com.amanganiello90.angular"
1212 },
13- "cordova-plugin-local-webserver " : {
13+ "cordova-plugin-httpd " : {
1414 "PACKAGE_NAME" : " com.amanganiello90.angular"
1515 }
1616 },
Original file line number Diff line number Diff line change 77 "is_top_level" : true ,
88 "variables" : {}
99 },
10- "cordova-plugin-local-webserver " : {
10+ "cordova-plugin-httpd " : {
1111 "source" : {
1212 "type" : " registry" ,
13- "id" : " git+https://github.com/fullStackApp/ cordova-plugin-local-webserver.git "
13+ "id" : " cordova-plugin-httpd "
1414 },
1515 "is_top_level" : true ,
1616 "variables" : {}
Original file line number Diff line number Diff line change 1-
2-
3- // device APIs are available
4- function onDeviceReady ( ) {
5- webserver . onRequest (
6- function ( request ) {
7- console . log ( "This is the request: " , request ) ;
8-
9- webserver . sendResponse (
10- request . requestId , {
11- status : 200 ,
12- body : '<html>Hello World</html>' ,
13- headers : {
14- 'Content-Type' : 'text/html'
15- }
16- } ) ;
17- } ) ;
18-
19- // Starts webserver with default port 8080
20- webserver . start ( ) ;
21-
22- //... after a long long time
23- // stop the server
24- //webserver.stop();
25- }
26-
271// Wait for device API libraries to load
282document . addEventListener ( "deviceready" , onDeviceReady , false ) ;
293
4+ // device APIs are available
5+ function onDeviceReady ( ) {
6+ startServer ( "" ) ;
7+ }
8+
9+ function startServer ( wwwroot ) {
10+
11+ httpd . getURL ( function ( url ) {
12+ httpd . startServer ( {
13+ 'www_root' : wwwroot ,
14+ 'port' : 8080
15+ } , function ( url ) {
16+ document . getElementById ( 'url' ) . innerHTML = "server is started: <a href='" + url + "' target='_blank'>" + url + "</a>" ;
17+ } , function ( error ) {
18+ alert ( 'failed to start server' ) ;
19+ } ) ;
20+
21+
22+ } , function ( ) { } ) ;
23+
24+ }
You can’t perform that action at this time.
0 commit comments