Bottle Web Framework ====================
Bottle is a fast and simple [WSGI][wsgi]-framework for the [Python Programming Language][py]. It offers request dispatching with url parameter support (routes), templates, key/value databases, a build-in HTTP server and adapters for many third party WSGI/HTTP-server and template engines - all in a single file and with no dependencies other than the Python Standard Library. For news, bugs and documentation visit the [bottle.py homepage][home]. [wsgi]: http://www.wsgi.org/wsgi/ [home]: http://bottle.paws.de/ [py]: http://python.org/ [www]: http://github.com/defnull/bottle [bottle-dl]: http://pypi.python.org/pypi/bottle Installation and Dependencies ----------------------------- You can install bottle with `easy_install bottle` or just [download][bottle-dl] bottle.py and place it in your project directory. There are no (hard) dependencies other than the Python Standard Library. [mako]: http://www.makotemplates.org/ [cherrypy]: http://www.cherrypy.org/ [flup]: http://trac.saddi.com/flup [paste]: http://pythonpaste.org/ [fapws3]: http://github.com/william-os4y/fapws3 Example ------- from bottle import route, run, request, response, send_file, abort, template @route('/') def hello_world(): return 'Hello World!' @route('/hello/:name') def hello_name(name): return 'Hello %s!' % name @route('/hello', method='POST') def hello_post(): name = request.POST['name'] return 'Hello %s!' % name @route('/static/:filename#.*#') def static_file(filename): send_file(filename, root='/path/to/static/files/') @route('/template/test') def template_test(): return template('template_name', title='Template Test', items=[1,2,3,'fly']) run(host='localhost', port=8080) Template example: %message = 'Hello world!'{{message}}
Items in list: {{len(items)}}