示例#1
0
 def setup(self):
     self.application = DjangoWSGIApp()
     if self.settings.DEBUG:
         from werkzeug import DebuggedApplication
         self.application = DebuggedApplication(self.application,
                                                evalex=True)
     settings.get_api = self.settings.get_api
     self.server = WSGIServer(self.settings.http_bind,
                              self.application,
                              log=None)
示例#2
0
def runserver():
    # Create the server
    application = DjangoWSGIApp()
    address = host, port
    server = WSGIServer( address, application )
    # Run the server
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        server.stop()
        sys.exit(0)
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()
from gevent.wsgi import WSGIServer

from django.core.management import setup_environ
import example.settings
import sys
setup_environ(example.settings)

from django.core.handlers.wsgi import WSGIHandler as DjangoWSGIApp
application = DjangoWSGIApp()

host = 'localhost'
port = 80
if len(sys.argv) > 1:
    url = sys.argv[1]

    if ':' in url:
        (host, port) = url.split(':')
    else:
        host = url

server = WSGIServer((host, int(port)), application)
print "Starting server on http://%s:%s" % (host, port)
server.serve_forever()
示例#4
0
def runserver(environ, start_response):
    if ws_connector(environ) != True:
        # If environment is not WebSocket, then call django server
        setup_environ(settings)
        application = DjangoWSGIApp()
        return application.__call__(environ, start_response)