application.py 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web
  5. name:application.py
  6. author:rabin
  7. """
  8. from url import *
  9. import tornado.web
  10. from demeter import *
  11. config = Demeter.config[Demeter.web]
  12. settings = {
  13. "static_path": os.path.join(os.path.dirname(__file__), "static"),
  14. "template_path": os.path.join(os.path.dirname(__file__), 'templates'),
  15. "cookie_secret": "61oETzKXQAGaYekL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
  16. "login_url": "/user/login",
  17. "xsrf_cookies": True,
  18. "debug": Demeter.bool(config['debug']),
  19. #"autoreload": Demeter.bool(config['autoreload']),
  20. "port": config['port'],
  21. "max_buffer_size": int(config['max_buffer_size']),
  22. "process": int(config['process'])
  23. }
  24. handlers = []
  25. def application_setting():
  26. handlers.append((r"/upload/(.*)", tornado.web.StaticFileHandler, {"path": Demeter.path + 'runtime/upload/'}))
  27. handlers.append((r"/static/(.*)", tornado.web.StaticFileHandler, {"path":"static"}))
  28. handlers.append((r"/(apple-touch-icon\.png)", tornado.web.StaticFileHandler, dict(path=settings['static_path'])))
  29. handlers.extend(url)
  30. application_setting()
  31. application = tornado.web.Application(handlers=handlers, **settings)