Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

app.py 1.2 KiB

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