Simple web server using nodejs

We can make a folder just like a web server using nodejs for quick jobs

First we can install connect and expressjs, serve-static with Node.js:

$ npm install connect serve-static

We can make .js file (serve.js) and write the below code in that file:

var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8080);

Then in cmd, run this file:

$ node server.js

Now we can access the local server in URL:

 http://localhost:8080/myfiles.html

And can exit by pressing:

ctrl+c

 7,552 total views,  7 views today

1 Comment

  1. great put up, very informative. I ponder why the other specialists of this sector don’t understand this.
    You should continue your writing. I’m confident, you’ve a great
    readers’ base already!

Leave a Reply

Your email address will not be published.