how.wtf

Create an HTTP server in one line

· Thomas Taylor

If you need a quick one-liner HTTP server from the command line, Python comes in handy.

How to create an HTTP server in one line

Python enables users to run a simple command to spin up an HTTP server:

1python -m http.server <PORT>

Example:

1python -m http.server 4000

By default, this command will serve the files in the current directory using a single-threaded HTTP server bound to localhost.

In addition, users may specify a different directory:

1python -m http.server <PORT> --directory <FILE PATH>

#Linux  

Reply to this post by email ↪