Most of the time working on a project required testing the files through a local HTTP server quickly, in this post lets us see the different options to quickly enable the HTTP server in the local system.
Python HTTP Server:
Ensure the Python is installed into your system. Python can be downloaded from https://www.python.org/
Now CD to the folder where your local files are placed
Start the server, the default port is 8000, specify a different port if required.
python3 -m http.serveror python3 -m http.server 80
If Python version returned is 2.X
python -m SimpleHTTPServer
The files are now accessible through an HTTP URL
http://localhost:8080/Test.htmlhttp://localhost:8080/Test-Data.txt
Node— HttpServer
The http-server is a simple, zero-configuration command-line static HTTP server.
Install the http-server through the following command(ensure the latest node/npm packages are installed)
npm install http-server -g
Now CD to the folder where your local files are placed
Start the server through the below command, the default port is 8080, if required specify the different port number
http-server .
http-server -p 8081 .
The files are now accessible through an HTTP URL
http://localhost:8080/Test.htmlhttp://localhost:8080/Test-Data.txt
Refer to https://www.npmjs.com/package/http-server for more details.
Serve
The serve server is a simple HTTP server
CD to the folder where your local files are placed(ensure the latest node/npm packages are installed)
npx serve
Now the local files can be accessed through HTTP
Static-server
A simple http server to serve static resource files from a local directory.
CD to the folder where your local files are placed(ensure the latest node/npm packages are installed)
npx static-server
Now the local files can be accessed through HTTP
Web Server for Chrome
A Web Server for Chrome serves web pages from a local folder using HTTP
Install the “Web Server for Chrome” plugin and launch the app
Select the folder where the files are located, change the port number if required also other configurations
Now the files are accessible through HTTP(HTTPS can be enabled if required)
Fenix Webserver
Simple static desktop web server, download from https://github.com/coreybutler/fenix/releases
Execute Fenix.exe, Create a new web server by selecting the local folder
Now the files are accessible through HTTP
There are several ways to run a local static server, select an option based on your need and simplicity.