I have installed a node-http-server
module. I launch it from myDir
on localhost port 8000. In myDir
I have index.html.
If I request (from the browser) http://localhost:8000/
I get index.html
, which is OK and good.
If I request though http://localhost:8000/anything
I do not get any response from the server.
Here's the Code I used (app.js):
const server=require('node-http-server');
var fs = require("fs");
var config = new server.Config;
config.root=__dirname;
config.server.index='index.html';
function getReq(req, res, body,enc) {
console.log("got rewq");
var content = fs.readFileSync('index.html', 'utf8');
body.value = content;
}
server.deploy({port:8000});
I found that the same question asked in this link: node http-server to respond with index.html to any request . But it was for http-server
module. I am using node-http-server
module.
I read documentation in https://github.com/RIAEvangelist/node-http-server. But can't find any suitable solutions. Help me with Some solutions.