Wednesday, November 16, 2016

HTML Web Server for Angular Research/Study

My recommendation is to use the http-server module of Node.js. Node.js is available cross-platform and can be installed fromhttp://nodejs.org/Once Node.js is installed, installing the http-server module and running the http server are easy. Open the command line and type the following command:

npm install http-server –g

This installs the HTTP server at the global level. To run the server, just navigate to the folder where the app code resides, or open the folder from where we want to serve static files, and type this:

http-server

You will have an HTTP server running at http://localhost:8080 that can serve files from the current directory.

To run the server on port 80 so you don't have to append the port every time you start the server type this:

sudo http-server -p 80

You will not have an HTTP server running on http://localhost that can serve files from the current directory. Note we used sudo in the case above as most systems wouldn't allow you to work with port 80. You'll need to be in the sudoers file to be able to access sudo.


The http-server module does support some startup configurations. Check the documentation at https://github.com/nodeapps/http-server.


No comments:

Post a Comment