Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

server.py 2.4 KiB

14 anni fa
14 anni fa
14 anni fa
14 anni fa
14 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/env python
  2. # Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  3. #
  4. # MIT License (MIT)
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a
  7. # copy of this software and associated documentation files (the "Software"),
  8. # to deal in the Software without restriction, including without limitation
  9. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. # and/or sell copies of the Software, and to permit persons to whom the
  11. # Software is furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included in
  14. # all copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  17. # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  18. # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  19. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  20. # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  21. # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. #
  23. from __future__ import unicode_literals
  24. import cgi, cgitb, os, sys
  25. cgitb.enable()
  26. # import libs
  27. sys.path.append('..')
  28. sys.path.append('../lib')
  29. sys.path.append('../app')
  30. import conf
  31. import webnotes
  32. import webnotes.handler
  33. import webnotes.auth
  34. def init():
  35. webnotes.handler.get_cgi_fields()
  36. # init request
  37. try:
  38. webnotes.http_request = webnotes.auth.HTTPRequest()
  39. return True
  40. except webnotes.AuthenticationError, e:
  41. return True
  42. #except webnotes.UnknownDomainError, e:
  43. # print "Location: " + (conf.redirect_404)
  44. except webnotes.SessionStopped, e:
  45. if 'cmd' in webnotes.form_dict:
  46. webnotes.handler.print_json()
  47. else:
  48. print "Content-Type: text/html"
  49. print
  50. print """<html>
  51. <body style="background-color: #EEE;">
  52. <h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto">
  53. Updating.
  54. We will be back in a few moments...
  55. </h3>
  56. </body>
  57. </html>"""
  58. def respond():
  59. import webnotes
  60. if 'cmd' in webnotes.form_dict:
  61. webnotes.handler.handle()
  62. else:
  63. print "Content-Type: text/html"
  64. print
  65. print "<html><head><script>window.location.href='index.html';</script></head></html>"
  66. if __name__=="__main__":
  67. if init():
  68. respond()