PHP like web framework based on Genshi
PHP has a reputation for questionable language design. It does however have one outstanding feature, the ease with which someone can get started. It has excellent server support. To get started with PHP someone just needs to edit a file on disk and point a web browser towards it.
I thought it would be amusing to try and emulate this behaviour with Python. Thus mod_genshi was born. It's built using the Genshi templating package. Genshi was chosen ahead of Mako or Jinja2 as Genshi supports arbitrary Python blocks.
You (probably) DO NOT want to use mod_genshi. There is a HUGE number of web frameworks written in Python. Some notable projects include:
This is just a small sample of the current state of Python web frameworks. Please look around before deciding to use mod_genshi.
mod_genshi is very immature and NOT ready for production use. A shortened list of features that are still to be completed.
- Use WebOb to support static file handling. (#1)
- Improve the security controls around template loading. (#2)
- Load configuration from config file. (#3)
- Extend Python path for templates from configuration. (#4)
- Allow multiple application instances to co-exist. (#5)
Not to mention all the documentation that is required.
The mod_genshi WSGI application will load and render templates relative to the servers working directory.
mod_genshi includes a HTTP server based on the wsgiref module. It is only suitable for development. To use this development server. :
$ python -m mod_genshi.server
This will run the mod_genshi development server on port 8000. The port can be changed by passing using the -p command line flag. There are a number of flags all of which are described if called with -h or --help. :
$ python -m mod_genshi.server --help
Usage: python -m mod_genshi.server [options]
Options:
-h, --help show this help message and exit
-p PORT, --port=PORT Port that server will listen on
-b, --window Open a current web browser window for the server
-w, --newwindow Open a new web browser window for the server
-t, --newtab Open a new web browser tab for the server
-r, --autoraise Auto raise the web browser
The -b option can be used to open a browser window for your mod_genshi application.
gunicorn is popular WSGI server. To run mod_genshi using gunicorn. :
$ gunicorn mod_genshi.app:handler
See the gunicorn documentation for details on configuration.