Exemple #1
0
def init_common_context():
    from util import config
    global common_context
    common_context = {
        'cur_ver': config.get_current_version(),
        'base_path': '' if app.debug else config.get_base_path(),
    }
Exemple #2
0
def init_common_context():
    from util import config

    global common_context
    common_context = {
        "base_path": "" if app.debug else config.get_base_path(),
        "cur_ver": config.get_current_version(),
    }
Exemple #3
0
def main():
    base_path = config.get_base_path()
    settings = {
        'static_path': os.path.join(BASE_DIR, 'static'),
        'static_url_prefix': base_path + '/static/',
    }
    wsgi_app = wsgi.WSGIContainer(app)
    handlers = []
    if base_path:
        handlers += [(base_path, web.RedirectHandler, dict(url=base_path + '/'))]
    handlers += [(base_path + r'/.*', web.FallbackHandler, dict(fallback=wsgi_app))]
    tornado_app = web.Application(handlers, **settings)
    http_server = HTTPServer(tornado_app, ssl_options=get_ssl_option())
    http_server.listen(config.get_port(), config.get_address())
    print("Start success on port %d" % config.get_port())
    IOLoop.current().start()
Exemple #4
0
def init_bps():
    from util import config
    from base.router import base_bp
    from server.router import server_bp
    from v2ray.router import v2ray_bp
    bps = [
        base_bp,
        v2ray_bp,
        server_bp,
    ]
    if not app.debug:
        base_path = config.get_base_path()
        for bp in bps:
            bp.url_prefix = base_path + (bp.url_prefix if bp.url_prefix else '')
    global need_login_bps
    need_login_bps += [v2ray_bp, server_bp]
    [app.register_blueprint(bp) for bp in bps]
Exemple #5
0
def main():
    base_path = config.get_base_path()
    settings = {
        "static_path": os.path.join(BASE_DIR, "static"),
        "static_url_prefix": base_path + "/static/",
    }
    wsgi_app = wsgi.WSGIContainer(app)
    handlers = []
    if base_path:
        handlers += [(base_path, web.RedirectHandler,
                      dict(url=base_path + "/"))]
    handlers += [(base_path + r"/.*", web.FallbackHandler,
                  dict(fallback=wsgi_app))]
    tornado_app = web.Application(handlers, **settings)
    if config.get_v2_ext_tls():
        http_server = HTTPServer(tornado_app, xheaders=True)
    else:
        http_server = HTTPServer(tornado_app, ssl_options=get_ssl_option())
    http_server.listen(config.get_port(), config.get_address())
    print("Start success on port %d" % config.get_port())
    IOLoop.current().start()