本文整理汇总了Python中starlette.types.ASGIApp方法的典型用法代码示例。如果您正苦于以下问题:Python types.ASGIApp方法的具体用法?Python types.ASGIApp怎么用?Python types.ASGIApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类starlette.types
的用法示例。
在下文中一共展示了types.ASGIApp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from starlette import types [as 别名]
# 或者: from starlette.types import ASGIApp [as 别名]
def __init__(
self,
routes: List[routing.BaseRoute] = None,
redirect_slashes: bool = True,
default: ASGIApp = None,
dependency_overrides_provider: Any = None,
route_class: Type[APIRoute] = APIRoute,
default_response_class: Type[Response] = None,
on_startup: Sequence[Callable] = None,
on_shutdown: Sequence[Callable] = None,
) -> None:
super().__init__(
routes=routes,
redirect_slashes=redirect_slashes,
default=default,
on_startup=on_startup,
on_shutdown=on_shutdown,
)
self.dependency_overrides_provider = dependency_overrides_provider
self.route_class = route_class
self.default_response_class = default_response_class
示例2: __init__
# 需要导入模块: from starlette import types [as 别名]
# 或者: from starlette.types import ASGIApp [as 别名]
def __init__(
self,
app: ASGIApp,
db_url: Optional[Union[str, URL]] = None,
custom_engine: Optional[Engine] = None,
engine_args: Dict = None,
session_args: Dict = None,
):
super().__init__(app)
global _Session
engine_args = engine_args or {}
session_args = session_args or {}
if not custom_engine and not db_url:
raise ValueError("You need to pass a db_url or a custom_engine parameter.")
if not custom_engine:
engine = create_engine(db_url, **engine_args)
else:
engine = custom_engine
_Session = sessionmaker(bind=engine, **session_args)
示例3: __init__
# 需要导入模块: from starlette import types [as 别名]
# 或者: from starlette.types import ASGIApp [as 别名]
def __init__(self, app: ASGIApp, filter_unhandled_paths: bool = False) -> None:
super().__init__(app)
self.filter_unhandled_paths = filter_unhandled_paths
示例4: __init__
# 需要导入模块: from starlette import types [as 别名]
# 或者: from starlette.types import ASGIApp [as 别名]
def __init__(
self,
app: ASGIApp,
callback_url: str = "https://localhost:8000/kc/callback",
redirect_uri: str = "/",
logout_uri: str = "/kc/logout",
) -> None:
self.app = app
self.callback_url = callback_url
self.redirect_uri = redirect_uri
self.logout_uri = logout_uri
self.kc = Client(callback_url)
示例5: __init__
# 需要导入模块: from starlette import types [as 别名]
# 或者: from starlette.types import ASGIApp [as 别名]
def __init__(self, app: ASGIApp, client: Client):
"""
Args:
app (ASGIApp): Starlette app
client (Client): ElasticAPM Client
"""
self.client = client
if self.client.config.instrument:
elasticapm.instrumentation.control.instrument()
super().__init__(app)
示例6: __init__
# 需要导入模块: from starlette import types [as 别名]
# 或者: from starlette.types import ASGIApp [as 别名]
def __init__(self, app: ASGIApp, config: GraphQLConfig):
self.app = app
self.config = config