本文整理匯總了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