I’m not a Python pro, I use it mostly for REST API interactions so this might be a “discovering America” type of post for some of you but I found it super interesting and useful! And no, it’s not about writing a web server in Python. It’s about starting a built-in one that comes with every Python installation, whether you’re using a Linux, MacOS or Windows.
Using cmd, shell or terminal just enter a directory you would like to become a root folder of your temporary web server:
Then start the web server on a chosen port using this command:
python -m SimpleHTTPServer 8080
The server provides standard GET and HEAD request handlers so you can use it for file sharing, simple HTML websites and general testing. I used it for UAG web reverse proxy testing. It works over localhost and regular IP in your network.
You can find out more details in official Python 3 documentation
If you wish to bind the server to specific IP address (localhost for instance) you can use this syntax:
python3 -m http.server --bind 127.0.0.1 8000