SoFunction
Updated on 2024-11-18

A quick python implementation of setting up a super simple web server

As an interim test using python commands to build web tests is the best option;

CD switch to the current directory just need a python command to quickly build a simple web server, python linux comes with no additional configuration and installation feeling is still very good to use;

python open web server command

python -m SimpleHTTPServer 8080

The port number can specify any port that is not occupied, but must be able to pass through a firewall;

After executing the above commands, just enter the IP address plus the port number directly

http://:port number/trails e.g. http://192.168.0.12/8080

If there is no index file it supports directory listings

This python server contains:

BaseHTTPServer: provides the basic Web services and processor classes , respectively HTTPServer and BaseHTTPRequestHandler.
SimpleHTTPServer: Contains the SimpleHTTPRequestHandler class that performs GET and HEAD requests.
CGIHTTPServer: Contains classes that handle POST requests and execute CGIHTTPRequestHandler.