关于文章 django

django linux python tornado wsgi

使用tornado回调启动django

使用tornado回调启动django

使用tornado回调启动django

import os
import sys
from tornado.options import options, define, parse_command_line
import django.core.handlers.wsgi
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.wsgi
from django.core.wsgi import get_wsgi_application
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
os.environ['DJANGO_SETTINGS_MODULE'] = "tornago.settings"

define('port', type=int, default=8000)


def main():
    parse_command_line()
    wsgi_app = tornado.wsgi.WSGIContainer(get_wsgi_application())
    tornado_app = tornado.web.Application(

        [('.*', tornado.web.FallbackHandler, dict(fallback=wsgi_app)),]
    )
    server = tornado.httpserver.HTTPServer(tornado_app)
    server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()

if __name__ == '__main__':
    main()