server in one line in python

Here is a one-liner Python code to run a simple HTTP server:

main.py
python -m http.server
22 chars
2 lines

This command will start a web server at port 8000 by default, and serve files from the current directory. You can specify a different port number as follows:

main.py
python -m http.server 8080
27 chars
2 lines

This will start the web server at port 8080.

Note that while this method is convenient for simple web serving needs, it is not recommended for production use as it lacks proper security and error handling features.

gistlibby LogSnag