views:

165

answers:

3

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.

+2  A: 

Yes, you can set your code up like this and intercept the requests yourself. However, you will have to parse the URL's yourself. Not really a big deal if you do not have that many, but it is work...

Justin Ethier
+3  A: 

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://bottle.paws.de/

truppo
A: 

Maybe the VerseMatch project and related recipes over at ActiveState is something you would be interested in examining? It implements a small application using the standard library for dynamic running.

Noctis Skytower