def _inner(app_factory, hostname=None, port=None, server='simple'): from inyoka.core.api import ctx from inyoka.utils.urls import get_host_port_mapping, make_full_domain _hostname, _port = get_host_port_mapping(make_full_domain())[:-1] if hostname is None: hostname = _hostname if port is None: port = _port app = app_factory() def _simple(): from werkzeug.serving import run_simple run_simple(hostname, port, app, threaded=False, processes=1, use_reloader=True, use_debugger=False) def _eventlet(): from eventlet import api, wsgi wsgi.server(api.tcp_listener((hostname, port)), app) def _cherrypy(): from cherrypy.wsgiserver import CherryPyWSGIServer server = CherryPyWSGIServer( (hostname, port), app, server_name=ctx.cfg['base_domain_name'], request_queue_size=500) server.start() def _tornado(): from tornado import httpserver, ioloop, wsgi container = wsgi.WSGIContainer(app) http_server = httpserver.HTTPServer(container) http_server.listen(port, hostname) ioloop.IOLoop.instance().start() def _gevent(): from gevent import monkey monkey.patch_all() from gevent.wsgi import WSGIServer WSGIServer((hostname, port), app).serve_forever() mapping = { 'simple': _simple, 'eventlet': _eventlet, 'cherrypy': _cherrypy, 'tornado': _tornado, 'gevent': _gevent, } # run actually the server mapping[server]()
def _inner(app_factory, hostname=None, port=None, server='simple'): from inyoka.core.api import ctx from inyoka.utils.urls import get_host_port_mapping, make_full_domain _hostname, _port = get_host_port_mapping(make_full_domain())[:-1] if hostname is None: hostname = _hostname if port is None: port = _port app = app_factory() def _simple(): from werkzeug.serving import run_simple run_simple(hostname, port, app, threaded=False, processes=1, use_reloader=True, use_debugger=False) def _eventlet(): from eventlet import api, wsgi wsgi.server(api.tcp_listener((hostname, port)), app) def _cherrypy(): from cherrypy.wsgiserver import CherryPyWSGIServer server = CherryPyWSGIServer((hostname, port), app, server_name=ctx.cfg['base_domain_name'], request_queue_size=500) server.start() def _tornado(): from tornado import httpserver, ioloop, wsgi container = wsgi.WSGIContainer(app) http_server = httpserver.HTTPServer(container) http_server.listen(port, hostname) ioloop.IOLoop.instance().start() def _gevent(): from gevent import monkey; monkey.patch_all() from gevent.wsgi import WSGIServer WSGIServer((hostname, port), app).serve_forever() mapping = { 'simple': _simple, 'eventlet': _eventlet, 'cherrypy': _cherrypy, 'tornado': _tornado, 'gevent': _gevent, } # run actually the server mapping[server]()
def get_base_url(cls): subdomain, mount = ctx.cfg['routing.urls.' + cls.name].split(':', 1) url = make_full_domain(subdomain, mount) return url