I want to write a simple python web application to provide a gui to a command line program (think of hg serve, for example). It would run locally only. I don’t want it to have any external dependencies for an easier deployment, so python web programming in general wouldn’t apply here
How can it be done with a minimal hassle? Any pointer how to do it easily with cgi or wsgi, string.Template or string.Formatter? I’d prefer a Python 2.6 solution, but even a Python 3.x one is OK. I’d also prefer using a few html templates to manually assembling html together.
UPDATE:
The ideal solution would include ways
- to process a form
- to upload/download a file
- to output html
- to start a webserver
The wsgiref package from the standard library has a simple server to serve wsgi applications. You can use it to run your own framework-less wsgi application, a minimal wsgi application isn’t terribly difficult (see the hello world example at the end of the wsgiref documentation page)
You might want to relax the “standard library” requirement a little. You’re going to have “dependencies” on your own modules anyway, is it really that bad to use something where someone else has already done the work? Some of the so-called “microframeworks” shouldn’t be too much of a problem for deployment. Bottle for example, comes as a single file module and has no dependencies other than stdlib (haven’t used Bottle yet myself, but I picked that one as an example mainly because of the single file/no dependencies)