|
- #!/usr/bin/python
- # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; -*-
-
- #
- # esempio minimo di controller WSGI
- #
- def application( environ, start_response ):
- start_response( '200 OK', [('content-type', 'text/html')] )
- return [ 'Greetings from demo' ]
-
- #
- # funzioni specializzate per GET e POST.
- # _se_ presenti hanno la precedenza rispetto ad 'application'
- #
- def get( environ, start_response ):
- import template
-
- start_response( '200 OK', [('content-type', 'text/html; charset=utf-8')] )
-
- return [ template.render(
- content='''
- Greetings from demo (GET)<br>
- {% for i in range(a): %}
- {% = i %}<br>
- {% pass %}
- <br>
- <span style='font-size:10px;'>(questo contenuto è generato da un template)</span>
- ''',
-
- context=dict(a=5),
-
- delimiters=( '{%', '%}' )
- )
- ]
-
- def post( environ, start_response ):
- start_response( '200 OK', [('content-type', 'text/html')] )
- return [ 'Greetings from demo (POST)' ]
-
-
-
- """
- @template( 'hello_world.tmpl' )
- def render( environ ):
- return { 'v1': 100, 'cube':lambda x: x**3 }
- """
|