Node HTTP Server is a simple HTTP server based on Node.js. It provides a lightweight web server that can handle HTTP requests and serve static files.
node-http-server
can easily host static files on a local machine, including HTML, CSS, JavaScript, images, videos (which can be played directly), and other common static resources.node-http-server
implements video on-demand and playback starting from any position in the video by supporting HTTP Range Requests.node-http-server
supports logging request information to the console, making it easy to debug and monitor.node-http-server
allows changing the server's port number and the directory being hosted by modifying theapp.js
file.
Since the node-http-server
project has not been published on npm, you need to clone the project first.
- Clone the repository from GitHub to your local computer:
git clone https://github.com/rosercode/node-http-server.git
- Go to the
node-http-server
directory and install dependencies:
cd node-http-server
npm install
If you need to install it globally:
npm install . -g
- In the
node-http-server
directory, use the following command to start the server:
node app.js
- Enter the following address in the browser to access the hosted static files:
http://localhost:3000
node-http-server
supports the following command-line arguments:
-p, --port <port>
: Specify the port number of the server, the default is3000
.-d, --dir <directory>
: Specify the directory to host, the default is.
(current directory).-debug
: Enable request logging, disabled by default.
To use command-line arguments, pass them to the app.js
script when starting the server. For example:
node app.js --dir=G:\video --port=30001 --debug=true
Contributions and improvements to the node-http-server
server are welcome. If you find any bugs or have any improvement suggestions, please submit an issue or pull request on GitHub.
node-http-server
is open-sourced under the MIT license.