Advertisement
include

Untitled

Jan 2nd, 2014
2,534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PyCon 0.39 KB | None | 0 0
  1. import bottle
  2.  
  3. from bottle import jinja2_template as template
  4. from jinja2 import Environment
  5.  
  6.  
  7. def cut(value):
  8.     return value[:7]
  9.  
  10. env = Environment()
  11. env.filters['ss'] = cut
  12.  
  13.  
  14. @bottle.route('/')
  15. def test():
  16.     foo = "klsjadlkjdalkdjdaskldjad007"
  17.     return template('''
  18.  
  19. foo value: {{ ss(foo) }}
  20. and {{ foo|ss }}
  21. ''', foo=foo)
  22.  
  23.  
  24. bottle.run(host='localhost', port=9090, debug=True, reloader=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement