jeudi 28 février 2019

Localhost page cannot be found using node-static

I am trying to serve static files using node-static. Later I intend to run this as windows service using nssm. I have run this before but don't know why, it doesn't work now.

Below is my code:

var http = require('http');

var nStatic = require('node-static');

var fileServer = new nStatic.Server(); ---> I also tried new nStatic.Server('filepath')
//setting middleware

http.createServer(function (req, res) { 
        fileServer.serve(req, res);
}).listen(9000);

I start the server using node server.js on command prompt. This is what I see

http://localhost:9000

node -v 10.15.2 npm -v 6.4.1

Can anyone please tell me what is that I am doing wrong ?




Aucun commentaire:

Enregistrer un commentaire