serv.py 984 B

123456789101112131415161718192021222324252627282930313233
  1. __author__ = 'alexander'
  2. import os
  3. import sys
  4. from tornado.options import options, define, parse_command_line
  5. import django.core.handlers.wsgi
  6. import tornado.httpserver
  7. import tornado.ioloop
  8. import tornado.web
  9. import tornado.wsgi
  10. from django.core.wsgi import get_wsgi_application
  11. _HERE = os.path.abspath(os.path.dirname(__file__))
  12. sys.path.append(_HERE)
  13. sys.path.append(os.path.join(_HERE,'common'))
  14. os.environ['DJANGO_SETTINGS_MODULE'] = "xdcjing.settings"
  15. def main(port):
  16. wsgi_app = tornado.wsgi.WSGIContainer(
  17. #django.core.handlers.wsgi.WSGIHandler()
  18. get_wsgi_application()
  19. )
  20. tornado_app = tornado.web.Application(
  21. [('.*', tornado.web.FallbackHandler, dict(fallback=wsgi_app)),
  22. ],debug=False)
  23. server = tornado.httpserver.HTTPServer(tornado_app)
  24. server.listen(port)
  25. tornado.ioloop.IOLoop.instance().start()
  26. if __name__ == '__main__':
  27. main(int(sys.argv[1]))