Ejemplo n.º 1
0
    def startserver(o, func, port):
        from web.httpserver import WSGIServer, StaticMiddleware
        func = StaticMiddleware(func)
        func = MyLogMiddleware(func)

        o.server = WSGIServer(("0.0.0.0", port), func)

        log().info("Web interface listening on http://0.0.0.0:%d/" % port)

        o.server.start()
Ejemplo n.º 2
0
def run_server(func, server_address=('0.0.0.0', 8080)):
    """This function same as runsimple from web/httpserver
    except removed LogMiddleware because we use
    HTTPLoggerMiddleware instead
    """
    global server
    func = StaticMiddleware(func)
    server = WSGIServer(server_address, func)
    print('http://%s:%d/' % server_address)

    try:
        server.start()
    except (KeyboardInterrupt, SystemExit):
        server.stop()
Ejemplo n.º 3
0
def pro(port):
    # run cherrypy 'production' server
    print "Running server on port", str(port)
    print "Quit the server with CTRL-BREAK"

    import django.core.handlers.wsgi
    from web.httpserver import WSGIServer, StaticMiddleware, LogMiddleware

    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    func = django.core.handlers.wsgi.WSGIHandler()
    func = StaticMiddleware(func)
    func = LogMiddleware(func)

    server = WSGIServer(('localhost', port), func)
    server.timeout = 50

    try:
        server.start()
    except KeyboardInterrupt:
        server.stop()
Ejemplo n.º 4
0
import os
import leancloud
from gevent.pywsgi import WSGIServer
from geventwebsocket.handler import WebSocketHandler
from web.httpserver import StaticMiddleware

from app import app

APP_ID = os.environ['LC_APP_ID']
MASTER_KEY = os.environ['LC_APP_MASTER_KEY']
PORT = int(os.environ['LC_APP_PORT'])

leancloud.init(APP_ID, master_key=MASTER_KEY)

engine = app.wsgifunc()
if os.environ.get('LC_HTTPS_ON', 0):
    engine = leancloud.HttpsRedirectMiddleware(engine)
engine = leancloud.Engine(engine)
engine = StaticMiddleware(engine)
application = engine

if __name__ == '__main__':
    # 只在本地开发环境执行的代码
    app.debug = True
    server = WSGIServer(('localhost', PORT),
                        application,
                        handler_class=WebSocketHandler)
    #server = WSGIServer(('localhost', PORT), application)
    server.serve_forever()
Ejemplo n.º 5
0
 def __init__(self, app):
     StaticMiddleware.__init__(self, app, "/js/")
Ejemplo n.º 6
0
 def __init__(self, app, prefix="/" + rec_path):
     StaticMiddleware.__init__(self, app, prefix)
 def run(self, port=8080):
     '''starts web server'''
     # 'lambda app: StaticMiddleware(app, '/webserver/')' is used to allow static files to be hosted from within the webserver folder
     func = self.wsgifunc(lambda app: StaticMiddleware(app, '/webserver/'))
     return web.httpserver.runsimple(func, ('0.0.0.0', port))
Ejemplo n.º 8
0
 def __init__(self, app):
     StaticMiddleware.__init__(self, app, '/dashboards/')
Ejemplo n.º 9
0
 def __init__(self, app):
     StaticMiddleware.__init__(self, app, '/dashboards/')
Ejemplo n.º 10
0
 def __init__(self, app, prefix='static/', url_prefix='/', root=None):
     self._root = root
     self._url_prefix = url_prefix
     StaticMiddleware.__init__(self, app, url_prefix + prefix)