コード例 #1
0
ファイル: app.py プロジェクト: wekesa/apistar
    def __init__(self,
                 routes: List[routing.Route] = None,
                 commands: List[Callable] = None,
                 settings: Dict[str, Any] = None) -> None:
        from apistar.settings import Settings
        from apistar.templating import Templates
        from apistar.backends.sqlalchemy import SQLAlchemy

        routes = [] if (routes is None) else routes
        commands = [] if (commands is None) else commands

        self.routes = routes
        self.commands = list(self.built_in_commands) + commands
        self.settings = Settings(settings or {})

        initial_types = [App]  # type: List[type]
        self.preloaded = {
            'app': self
        }
        if 'TEMPLATES' in self.settings:
            initial_types.append(Templates)
            self.preloaded['templates'] = Templates.build(self.settings)
        if 'DATABASE' in self.settings:
            initial_types.append(SQLAlchemy)
            self.preloaded['sql_alchemy'] = SQLAlchemy.build(self.settings)
            self.commands += [cmd.create_tables]

        self.router = routing.Router(self.routes, initial_types)
        self.wsgi = get_wsgi_server(app=self)
        self.click = get_click_client(app=self)
コード例 #2
0
ファイル: app.py プロジェクト: tadhg-ohiggins/apistar
    def __init__(self,
                 routes: routing.RoutesConfig = None,
                 commands: List[Callable] = None,
                 settings: Dict[str, Any] = None) -> None:
        from apistar.settings import Settings
        initial_types = [App, routing.Router]  # type: List[type]

        routes = [] if (routes is None) else routes
        commands = [] if (commands is None) else commands

        self.routes = routes
        self.commands = list(self.built_in_commands) + commands
        self.settings = Settings(settings or {})
        self.router = routing.Router(self.routes, initial_types)

        self.preloaded = {
            'app': self,
            'router': self.router,
        }
        preload_state(self.preloaded, self.routes)
        if 'sql_alchemy' in self.preloaded:
            self.commands += [cmd.create_tables]

        self.wsgi = get_wsgi_server(app=self)
        self.click = get_click_client(app=self)
コード例 #3
0
ファイル: app.py プロジェクト: yoshimaa/apistar
    def __init__(self, routes=None, commands=None):
        routes = [] if (routes is None) else routes
        commands = [] if (commands is None) else commands

        self.routes = routes
        self.commands = list(self.built_in_commands) + commands

        self.router = routing.Router(self.routes)
        self.wsgi = get_wsgi_server(app=self)
        self.click = get_click_client(app=self)