Home » » Simplest python server using Python

Simplest python server using Python

If you want to use python to build a small server or just want to provide
web-base api with minimal efforts, you can just use python SimpleHTTPServer package as below:

import SimpleHTTPServer

With only two lines, that's really awesome. Right? 

Or you can do as follows: 
python -m SimpleHTTPServer
the default port is 8000. 

you can also alias it in your .bash_profile file 
alias http="python -m SimpleHTTPServer"

1. For web-based server, you can just return a json file for communication. 



Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions. 
Flask is as simple as SimpleHTTPServer, but it is more powerful in many ways. You can also find rich documentation on its official website. 

Popular Posts