Search code examples
pythonpostgetwebserversimplehttpserver

Is it possible to write dynamic web pages in Python with the Really Simple HTTP Server?


I know that with the SimpleHTTPServer I can make my directories accessible by web-browsers via Internet. So, I run just one line of the code and, as a result, another person working on another computer can use his/her browser to see content of my directories.

But I wander if I can make more complicated things. For example, somebody uses his/her browser to load my Python program with a set of parameter (example.py?x=2&y=2) and, as a result, he/she sees the HTML page generated by the Python program (not the Python program).

I also wander if I can process html form submitted to the SimpleHTTPServer.


Solution

  • While it is possible, you have to do pretty much everything yourself (parsing request parameters, handle routing, etc).

    If you are not looking to get experience in creating web-frameworks, but just want to create a small site you should probably use a minimalistic framework instead.

    Try Bottle, a simple single-file web framework: http://bottlepy.org