No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

hace 12 años
hace 12 años
hace 12 años
hace 11 años
hace 12 años
hace 12 años
hace 12 años
hace 11 años
hace 12 años
hace 12 años
hace 12 años
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 webnotes.middlewares import StaticDataMiddleware
  9. from werkzeug.exceptions import HTTPException
  10. from webnotes import get_config
  11. import mimetypes
  12. import webnotes
  13. import webnotes.handler
  14. import webnotes.auth
  15. import webnotes.webutils
  16. local_manager = LocalManager([webnotes.local])
  17. @Request.application
  18. def application(request):
  19. webnotes.local.request = request
  20. try:
  21. site = webnotes.utils.get_site_name(request.host)
  22. webnotes.init(site=site)
  23. webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
  24. for k, v in (request.form or request.args).iteritems() })
  25. webnotes.local._response = Response()
  26. try:
  27. webnotes.http_request = webnotes.auth.HTTPRequest()
  28. except webnotes.AuthenticationError, e:
  29. pass
  30. if webnotes.form_dict.cmd:
  31. webnotes.handler.handle()
  32. else:
  33. webnotes.webutils.render(webnotes.request.path[1:])
  34. except HTTPException, e:
  35. return e
  36. finally:
  37. if webnotes.conn:
  38. webnotes.conn.close()
  39. return webnotes._response
  40. application = local_manager.make_middleware(application)
  41. application = StaticDataMiddleware(application, {
  42. '/': 'public',
  43. })
  44. def serve(port=8000):
  45. from werkzeug.serving import run_simple
  46. run_simple('0.0.0.0', int(port), application, use_reloader=True,
  47. use_debugger=True, use_evalex=True)