Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

47 řádky
1.1 KiB

  1. #!/usr/bin/python
  2. # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; -*-
  3. #
  4. # esempio minimo di controller WSGI
  5. #
  6. def application( environ, start_response ):
  7. start_response( '200 OK', [('content-type', 'text/html')] )
  8. return [ 'Greetings from demo' ]
  9. #
  10. # funzioni specializzate per GET e POST.
  11. # _se_ presenti hanno la precedenza rispetto ad 'application'
  12. #
  13. def get( environ, start_response ):
  14. import template
  15. start_response( '200 OK', [('content-type', 'text/html; charset=utf-8')] )
  16. return [ template.render(
  17. content='''
  18. Greetings from demo (GET)<br>
  19. {% for i in range(a): %}
  20. {% = i %}<br>
  21. {% pass %}
  22. <br>
  23. <span style='font-size:10px;'>(questo contenuto è generato da un template)</span>
  24. ''',
  25. context=dict(a=5),
  26. delimiters=( '{%', '%}' )
  27. )
  28. ]
  29. def post( environ, start_response ):
  30. start_response( '200 OK', [('content-type', 'text/html')] )
  31. return [ 'Greetings from demo (POST)' ]
  32. """
  33. @template( 'hello_world.tmpl' )
  34. def render( environ ):
  35. return { 'v1': 100, 'cube':lambda x: x**3 }
  36. """