Simple Python Server
Tags: python
Contents
Introduction
The Python3 standard library includes a module to set up a static file server.
It is the http.server
module.
You can use this to test and share files locally.
Command
Run this command from the shell:
python3 -m http.server
This will create a local server you can access at http://localhost:8000
.
You can specify a different port, for e.g. the port 4000:
python3 -m http.server 4000
This will create a local server at http://localhost:4000
.
Conclusion
This is not a secure and production ready setup.
But it comes in handy for testing and sharing local files within a home or small office network.
I test website front-ends that don’t include any code from JavaScript, PHP, Python, etc.
If you have Termux installed, you can run the server from an Android device as well.