新手初入nodejs, 有些配置問題請各位指教
index.js
var server = require("./server");
var router = require("./router");
server.start(router.route);
router.js
function route(pathname) {
console.log("About to route a request for " + pathname);
}
exports.route = route;
server.js
var http = require("http");
var url = require("url");
function start(route) {
function onRequest(request, response) {
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname + " received.");
route(pathname);
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has started.");
}
exports.start = start;
我要在command prompt 上執行 node index.js ,才可以在chrome 運行 http://localhost:8888
請問如何WEB SERVER 上運行,而不需要輸入 node index.js
可否在IIS 上運行? 因為書本上沒有教如何發行到網上,所以例子都是LOCAL, 謝謝
使用Digital Ocean超快速搭建出部屬NodeJs的主機
https://coolmandiary.blogspot.com/2021/01/digital-oceannodejs.html
如何在Digital Ocean主機上配置購買好的Domain Name_GoDaddy與NoIP示範
https://coolmandiary.blogspot.com/2021/02/digital-oceandomain-name.html