Python - HTTP Server

Tags: python server 

Contents

Introduction

Create a simple static file server with Python 3 http.server module (part of its standard Library).

You can use this to test and share files locally.

Command

Run this command from the shell:

python3 -m http.server

This creates a local server accessible at http://localhost:8000.

Specify a different port:

python3 -m http.server 4000

Conclusion

This isn’t a secure and production ready command, so use it solely for testing and sharing local files.

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 you Android device as well.

Further reads

http.server
How do you set up a local testing server?

Reply to this post with email.

Go to Top
Return to Posts
Stay updated with RSS