- Sort Score
- Result 10 results
- Languages All
Results 51 - 60 of 140 for kAsync (0.24 sec)
-
docs/zh/docs/advanced/events.md
# 事件:启动 - 关闭 **FastAPI** 支持定义在应用启动前,或应用关闭后执行的事件处理器(函数)。 事件函数既可以声明为异步函数(`async def`),也可以声明为普通函数(`def`)。 !!! warning "警告" **FastAPI** 只执行主应用中的事件处理器,不执行[子应用 - 挂载](sub-applications.md){.internal-link target=_blank}中的事件处理器。 ## `startup` 事件 使用 `startup` 事件声明 `app` 启动前运行的函数: ```Python hl_lines="8" {!../../../docs_src/events/tutorial001.py!} ``` 本例中,`startup` 事件处理器函数为项目数据库(只是**字典**)提供了一些初始值。 **FastAPI** 支持多个事件处理器函数。
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Thu Apr 18 19:53:19 UTC 2024 - 1.7K bytes - Viewed (0) -
docs_src/custom_response/tutorial006c.py
from fastapi import FastAPI from fastapi.responses import RedirectResponse app = FastAPI() @app.get("/pydantic", response_class=RedirectResponse, status_code=302) async def redirect_pydantic():
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri Mar 22 01:42:11 UTC 2024 - 237 bytes - Viewed (0) -
docs_src/header_params/tutorial002.py
from typing import Union from fastapi import FastAPI, Header app = FastAPI() @app.get("/items/") async def read_items( strange_header: Union[str, None] = Header(default=None, convert_underscores=False), ):
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 260 bytes - Viewed (0) -
docs_src/query_params_str_validations/tutorial014_py310.py
from fastapi import FastAPI, Query app = FastAPI() @app.get("/items/") async def read_items( hidden_query: str | None = Query(default=None, include_in_schema=False), ): if hidden_query: return {"hidden_query": hidden_query} else:
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 298 bytes - Viewed (0) -
docs_src/dependencies/tutorial005_an.py
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 558 bytes - Viewed (0) -
docs_src/query_params_str_validations/tutorial014_an_py310.py
from typing import Annotated from fastapi import FastAPI, Query app = FastAPI() @app.get("/items/") async def read_items( hidden_query: Annotated[str | None, Query(include_in_schema=False)] = None, ): if hidden_query: return {"hidden_query": hidden_query} else:
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 331 bytes - Viewed (0) -
docs_src/query_params_str_validations/tutorial014.py
from typing import Union from fastapi import FastAPI, Query app = FastAPI() @app.get("/items/") async def read_items( hidden_query: Union[str, None] = Query(default=None, include_in_schema=False), ): if hidden_query: return {"hidden_query": hidden_query} else:
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 330 bytes - Viewed (0) -
docs_src/extra_data_types/tutorial001.py
from datetime import datetime, time, timedelta from typing import Union from uuid import UUID from fastapi import Body, FastAPI app = FastAPI() @app.put("/items/{item_id}") async def read_items( item_id: UUID, start_datetime: datetime = Body(), end_datetime: datetime = Body(), process_after: timedelta = Body(), repeat_at: Union[time, None] = Body(default=None), ):
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri Apr 19 00:11:40 UTC 2024 - 755 bytes - Viewed (0) -
docs_src/query_params_str_validations/tutorial003_an_py39.py
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 343 bytes - Viewed (0) -
docs_src/query_params_str_validations/tutorial014_an.py
from typing import Union from fastapi import FastAPI, Query from typing_extensions import Annotated app = FastAPI() @app.get("/items/") async def read_items( hidden_query: Annotated[Union[str, None], Query(include_in_schema=False)] = None, ): if hidden_query: return {"hidden_query": hidden_query} else:
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 373 bytes - Viewed (0)