您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

60 行
1.3 KiB

  1. import sys, os
  2. sys.path.insert(0, '.')
  3. sys.path.insert(0, 'app')
  4. sys.path.insert(0, 'lib')
  5. from werkzeug.wrappers import Request, Response
  6. from werkzeug.local import LocalManager
  7. from werkzeug.wsgi import SharedDataMiddleware
  8. import mimetypes
  9. import webnotes
  10. import webnotes.handler
  11. import webnotes.auth
  12. import webnotes.webutils
  13. local_manager = LocalManager([webnotes.local])
  14. @Request.application
  15. def application(request):
  16. webnotes.local.request = request
  17. webnotes.init()
  18. webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
  19. for k, v in (request.form or request.args).iteritems() })
  20. webnotes.local._response = Response()
  21. try:
  22. webnotes.http_request = webnotes.auth.HTTPRequest()
  23. except webnotes.AuthenticationError, e:
  24. pass
  25. if webnotes.form_dict.cmd:
  26. webnotes.handler.handle()
  27. else:
  28. webnotes.webutils.render(webnotes.request.path[1:])
  29. return webnotes._response
  30. application = local_manager.make_middleware(application)
  31. application = SharedDataMiddleware(application, {
  32. '/': os.path.join(os.path.dirname(__file__), "..", "..", "public")
  33. })
  34. if __name__ == '__main__':
  35. import sys
  36. from werkzeug.serving import run_simple
  37. port = 8000
  38. if len(sys.argv) > 1:
  39. port = sys.argv[1]
  40. run_simple('localhost', int(port), application, use_reloader=True,
  41. use_debugger=True, use_evalex=True)