quart.views モジュール#
- class quart.views.MethodView#
ベース:
ViewHTTPメソッド(動詞)固有のビュークラス。
これは、動詞に基づいてメソッドを呼び出すように
dispatch_request()の実装を持ちます。つまり、GETリクエストはgetメソッドによって処理されます。例:class SimpleView(MethodView): async def get(id): return f"Get {id}" async def post(id): return f"Post {id}" app.add_url_rule('/<id>', view_func=SimpleView.as_view('simple'))
- async dispatch_request(**kwargs: Any) ResponseReturnValue#
オーバーライドしてレスポンスを返します。
これは、リクエストのview_args、つまりURLパラメータと共に呼び出されます。
- class quart.views.View#
ベース:
objectクラス構造内にルートを定義するために使用します。
Viewサブクラスは、リクエストに応答するために
dispatch_request()を実装する必要があります。リクエストのHTTP動詞に基づく自動メソッド検索については、MethodViewを参照してください。使用例:
class SimpleView: methods = ['GET'] async def dispatch_request(id): return f"ID is {id}" app.add_url_rule('/<id>', view_func=SimpleView.as_view('simple'))
クラスに注意してください。
- decorators#
ビューメソッドに適用するデコレータのリスト。デコレータはリストの順序で適用されます。
- 型:
ClassVar[list[Callable]]
- methods#
このビューが許可するメソッドのリスト。
- 型:
ClassVar[Collection[str] | None]
- provide_automatic_options#
設定されている場合、自動OPTIONSをTrueまたはFalseにオーバーライドします。
- 型:
ClassVar[bool | None]
- init_every_request#
リクエストごとにこのクラスの新しいインスタンスを作成します。
- 型:
ClassVar[bool]
- classmethod as_view(name: str, *class_args: Any, **class_kwargs: Any) RouteCallable#
- decorators: ClassVar[list[Callable]] = []#
- async dispatch_request(**kwargs: Any) ResponseReturnValue#
オーバーライドしてレスポンスを返します。
これは、リクエストのview_args、つまりURLパラメータと共に呼び出されます。
- init_every_request: ClassVar[bool] = True#
- methods: ClassVar[Collection[str] | None] = None#
- provide_automatic_options: ClassVar[bool | None] = None#