Skip to content

Commit 3ff3172

Browse files
author
Angelo Manganiello
committed
change plugin http cordova
1 parent 3b67749 commit 3ff3172

File tree

6 files changed

+28
-33
lines changed

6 files changed

+28
-33
lines changed

cordova-app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cordova cli 8.0.0
33
I 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

cordova-app/app/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
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>

cordova-app/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
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
}

cordova-app/app/plugins/android.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
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
},

cordova-app/app/plugins/fetch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
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": {}

cordova-app/server-cordova.js

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
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
282
document.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+
}

0 commit comments

Comments
 (0)