Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

62 rindas
1.4 KiB

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