register dispatchable wsgi application
187340
def register_app(self, name: str, app: Callable = None) -> Callable:
        
        if app is None:
            def dec(app):
                """ inner decorator for register app """
                assert app is not None
                self.register_app(name, app)
                return app
            return dec
        self.applications[name] = app
        return None
15017
def serve(application, host='127.0.0.1', port=8080):
	
	
	# Instantiate the server with a host/port configuration and our application.
	WSGIApplication(application, port=int(port), iface=host).run()
276547
def register(self, procedure=None, options=None):
        

        def decorator(func):
            if self._started:
                self.session.register(endpoint=func, procedure=procedure, options=options)
            else:

                def registerer():
                    self.session.register(endpoint=func, procedure=procedure, options=options)

                # Wait for the WAMP session to be started
                self._on_running_callbacks.append(registerer)
            return func

        return decorator
778520
def _work(self):
        """"""
        server = wsgi.Server(
            name=self._AGENT_BINARY,
            num_threads=CONF.AGENT.worker_count)
        server.start(
            application=_MetadataProxyHandler(),
            port=CONF.bind_port,
            host=CONF.bind_host)
        server.wait()
828416
def init_app(application):
    
    config = {k: v for k, v in application.config.items() if k in SCHEMA}

    kwargs = {'autorefresh': application.debug}

    kwargs.update((k[11:].lower(), v) for k, v in config.items())

    instance = whitenoise.WhiteNoise(application.wsgi_app, **kwargs)

    instance.add_files(application.static_folder, application.static_url_path)

    if not hasattr(application, 'extensions'):
        application.extensions = {}

    application.extensions['whitenoise'] = instance

    application.wsgi_app = instance
1285300
def register(self):
		
		logger.info('Sending registration to %s:%s', self.hostname, self.port)
		register = gntp.core.GNTPRegister()
		register.add_header('Application-Name', self.applicationName)
		for notification in self.notifications:
			enabled = notification in self.defaultNotifications
			register.add_notification(notification, enabled)
		if self.applicationIcon:
			if self._checkIcon(self.applicationIcon):
				register.add_header('Application-Icon', self.applicationIcon)
			else:
				resource = register.add_resource(self.applicationIcon)
				register.add_header('Application-Icon', resource)
		if self.password:
			register.set_password(self.password, self.passwordHash)
		self.add_origin_info(register)
		self.register_hook(register)
		return self._send('register', register)
357114
def bind(cls, app, *paths, methods=None, name=None, router=None, view=None):
        """"""
        cls.app = app
        if cls.app is not None:
            for _, m in inspect.getmembers(cls, predicate=inspect.isfunction):
                if not hasattr(m, ROUTE_PARAMS_ATTR):
                    continue
                paths_, methods_, name_ = getattr(m, ROUTE_PARAMS_ATTR)
                name_ = name_ or ("%s.%s" % (cls.name, m.__name__))
                delattr(m, ROUTE_PARAMS_ATTR)
                cls.app.register(*paths_, methods=methods_, name=name_, handler=cls)(m)

        @coroutine
        @functools.wraps(cls)
        def handler(request):
            return cls().dispatch(request, view=view)

        if not paths:
            paths = ["/%s" % cls.__name__]

        return routes_register(
            app, handler, *paths, methods=methods, router=router, name=name or cls.name)
558077
def wsgi_handler(func):
    

    @wraps(func)
    def inner(*args):
        self, environ, start_response, *args = args
        request = Request(environ)

        try:
            response = func(self, request)
        except Exception as err:
            raise
        else:
            return response(environ, start_response)

    return inner
1345308
def _build_wsgi_env(event, app_name):
    
    gateway = event['parameters']['gateway']
    request = event['parameters']['request']
    ctx = event['rawContext']
    headers = request['header']
    body = six.text_type(json.dumps(request['body']))

    # Render the path correctly so connexion/flask will pass the path params to
    # the handler function correctly.
    # Basically, this replaces "/foo/{param1}/bar/{param2}" with
    # "/foo/123/bar/456".
    path = gateway['resource-path'].format(
        **event['parameters']['request']['path']
    )
    environ = {
        'PATH_INFO': path,
        'QUERY_STRING': urlencode(request['querystring']),
        'REMOTE_ADDR': ctx['identity']['sourceIp'],
        'REQUEST_METHOD': ctx['httpMethod'],
        'SCRIPT_NAME': app_name,
        'SERVER_NAME': app_name,
        'SERVER_PORT': headers.get('X-Forwarded-Port', '80'),
        'SERVER_PROTOCOL': 'HTTP/1.1',
        'wsgi.version': (1, 0),
        'wsgi.url_scheme': headers.get('X-Forwarded-Proto', 'http'),
        'wsgi.input': StringIO(body),
        'wsgi.errors': StringIO(),
        'wsgi.multiprocess': False,
        'wsgi.multithread': False,
        'wsgi.run_once': False,
        'CONTENT_TYPE': headers.get('Content-Type', 'application/json'),
    }
    if ctx['httpMethod'] in ['POST', 'PUT', 'PATCH']:
        environ['CONTENT_LENGTH'] = str(len(body))

    for header_name, header_value in headers.items():
        wsgi_name = 'HTTP_{}'.format(header_name.upper().replace('-', '_'))
        environ[wsgi_name] = str(header_value)

    return environ
381653
async function register(server, options) {
    const validation = validateOptions(options);

    if (validation.error) {
        throw validation.error;
    }

    const {
        components,
        handlebars,
        helpersPath,
        path,
        uriContext,
        routes,
        rootDir
    } = validation.value;


    server.log(['info', 'windshield'], "application directory identified as: " + rootDir);

    server.views({
        engines: {html: handlebars},
        relativeTo: rootDir,
        path,
        helpersPath
    });

    const componentMap = ComponentMap(components);

    const hapiHandler = handlerComposer(componentMap);
    const hapiRoutes = processRoutes(hapiHandler, uriContext, routes);
    server.route(hapiRoutes);
    templateInit(handlebars);

    return componentMap.init(handlebars);
}
1320208
def _register(cls, app, **kwargs):
        

        # nav
        nav = __options__.get("nav", {})
        nav.setdefault("title", "Contact")
        nav.setdefault("visible", True)
        nav.setdefault("order", 100)
        title = nav.pop("title")
        render.nav.add(title, cls.page, **nav)

        # route
        kwargs["base_route"] = __options__.get("route", "/contact/")

        # App Option
        data = {
            "recipients": __options__.get("recipients"),
            "success_message": __options__.get("success_message",
                                               "Message sent. Thanks!")
        }

        @app.before_first_request
        def setup():
            if db._IS_OK_:
                try:
                    app_data.set(APP_DATA_KEY, data, init=True)
                except Exception as ex:
                    logging.fatal("mocha.contrib.app_data has not been setup. Need to run `mocha :dbsync`")
                    abort(500)

        # Call the register
        super(cls, cls)._register(app, **kwargs)
30339
def wsgi(self, environ, start_response):
        
        try:
            environ['bottle.app'] = self
            request.bind(environ)
            response.bind()
            out = self._cast(self._handle(environ), request, response)
            # rfc2616 section 4.3
            if response._status_code in (100, 101, 204, 304)\
            or request.method == 'HEAD':
                if hasattr(out, 'close'): out.close()
                out = []
            start_response(response._status_line, list(response.iter_headers()))
            return out
        except (KeyboardInterrupt, SystemExit, MemoryError):
            raise
        except Exception, e:
            if not self.catchall: raise
            err = '<h1>Critical error while processing request: %s</h1>' \
                  % html_escape(environ.get('PATH_INFO', '/'))
            if DEBUG:
                err += '<h2>Error:</h2>\n<pre>\n%s\n</pre>\n' \
                       '<h2>Traceback:</h2>\n<pre>\n%s\n</pre>\n' \
                       % (html_escape(repr(e)), html_escape(format_exc(10)))
            environ['wsgi.errors'].write(err)
            headers = [('Content-Type', 'text/html; charset=UTF-8')]
            start_response('500 INTERNAL SERVER ERROR', headers)
            return [tob(err)]
20986
def get_wsgi_server(
        self, sock, wsgi_app, protocol=HttpOnlyProtocol, debug=False
    ):
        """"""
        return wsgi.Server(
            sock,
            sock.getsockname(),
            wsgi_app,
            protocol=protocol,
            debug=debug,
            log=getLogger(__name__)
        )
713758
def init_app(self, app):
        '''
        '''
        self.app = app
        self._session_conf = app.config.get('BEAKER_SESSION', {
            'session.type': 'file',
            'session.data_dir': '/tmp/session/data',
            'session.lock_dir': '/tmp/session/lock'
        })
        app.wsgi_app = SessionMiddleware(app.wsgi_app, self._session_conf)
        app.session_interface = BeakerSessionInterface()
175033
def run(self):
        
        server_address = (self.host, self.port)
        threading = True
        if threading:
            httpd_cls = type('WSGIServer', (ThreadingMixIn, WSGIServer), {})
        else:
            httpd_cls = WSGIServer
        self.httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=False)
        wsgi_handler = get_internal_wsgi_application()
        self.httpd.set_app(wsgi_handler)
        self.is_ready.set()
        self.httpd.serve_forever()
1109827
def _register_file_server(self, app):
        
        if isinstance(self.driver, local.LocalStorageDriver) \
                and self.config["serve_files"]:
            server_url = self.config["serve_files_url"].strip("/").strip()
            if server_url:
                url = "/%s/<path:object_name>" % server_url

                @app.route(url, endpoint=SERVER_ENDPOINT)
                def files_server(object_name):
                    obj = self.get(object_name)
                    if obj is not None:
                        dl = flask_request.args.get("dl")
                        name = flask_request.args.get("name", obj.name)

                        if get_file_extension(name) != obj.extension:
                            name += ".%s" % obj.extension

                        _url = obj.get_cdn_url()
                        return send_file(_url,
                                         as_attachment=True if dl else False,
                                         attachment_filename=name,
                                         conditional=True)
                    else:
                        abort(404)
            else:
                warnings.warn("Flask-Cloudy can't serve files. 'STORAGE_SERVER_FILES_URL' is not set")
659580
def register_app(app):
    "  "

    from .views import users
    app.register_blueprint(users)

    from .oauth import config_oauth
    config_oauth(app)