Dieses Blog durchsuchen

Freitag, 19. August 2016

node.js: create a little bit more complex webserver

In the last tutorial, we have created a simple webserver. Lets create a little bit more complex webserver with node.js, which can serv different filetypes and check for errors on the filesystem.

Prerequisits

node.js installed
npm installed

Create a webserver


This webserver can dispatch a hand full of images , text, javascript and css

Create a file "server.js" and paste following code

This will create the webserver

Create a file to dispatch

Open a terminal in the projectroot and create a file "index.html" with following content
 



Start the webserver

Open a terminal in the projectroot and type:
$ node server.js 


Now you can surf http://localhost:1337/index.html and you should see "Testing"

Thats it

Keine Kommentare:

Kommentar veröffentlichen