- Sort Score
- Result 10 results
- Languages All
Results 321 - 330 of 781 for typing (0.07 sec)
-
tests/test_webhooks_security.py
from datetime import datetime from typing import Annotated from fastapi import FastAPI, Security from fastapi.security import HTTPBearer from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() bearer_scheme = HTTPBearer() class Subscription(BaseModel): username: str monthly_fee: float start_date: datetime @app.webhooks.post("new-subscription") def new_subscription(
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 4.5K bytes - Viewed (0) -
docs_src/dependencies/tutorial008d_an_py39.py
from typing import Annotated from fastapi import Depends, FastAPI, HTTPException app = FastAPI() class InternalError(Exception): pass def get_username(): try: yield "Rick" except InternalError: print("We don't swallow the internal error here, we raise again 😎") raise @app.get("/items/{item_id}") def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Feb 24 23:06:37 UTC 2024 - 734 bytes - Viewed (0) -
docs_src/dependencies/tutorial012_an_py39.py
from typing import Annotated from fastapi import Depends, FastAPI, Header, HTTPException async def verify_token(x_token: Annotated[str, Header()]): if x_token != "fake-super-secret-token": raise HTTPException(status_code=400, detail="X-Token header invalid") async def verify_key(x_key: Annotated[str, Header()]): if x_key != "fake-super-secret-key": raise HTTPException(status_code=400, detail="X-Key header invalid")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 746 bytes - Viewed (0) -
docs/en/docs/environment-variables.md
It would be roughly equivalent to typing: <div class="termy"> ```console $ /opt/custompython/bin/python ``` </div> //// //// tab | Windows The system will **find** the `python` program in `C:\opt\custompython\bin\python` and run it. It would be roughly equivalent to typing: <div class="termy"> ```console
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sun Aug 31 09:15:41 UTC 2025 - 8.1K bytes - Viewed (0) -
docs_src/security/tutorial007_an_py39.py
import secrets from typing import Annotated from fastapi import Depends, FastAPI, HTTPException, status from fastapi.security import HTTPBasic, HTTPBasicCredentials app = FastAPI() security = HTTPBasic() def get_current_username( credentials: Annotated[HTTPBasicCredentials, Depends(security)], ): current_username_bytes = credentials.username.encode("utf8") correct_username_bytes = b"stanleyjobson"
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Tue Mar 26 16:56:53 UTC 2024 - 1.1K bytes - Viewed (0) -
tests/test_form_default.py
from typing import Annotated, Optional from fastapi import FastAPI, File, Form from starlette.testclient import TestClient app = FastAPI() @app.post("/urlencoded") async def post_url_encoded(age: Annotated[Optional[int], Form()] = None): return age @app.post("/multipart") async def post_multi_part( age: Annotated[Optional[int], Form()] = None, file: Annotated[Optional[bytes], File()] = None, ):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 848 bytes - Viewed (0) -
docs_src/sql_databases/tutorial002_py39.py
from typing import Union from fastapi import Depends, FastAPI, HTTPException, Query from sqlmodel import Field, Session, SQLModel, create_engine, select class HeroBase(SQLModel): name: str = Field(index=True) age: Union[int, None] = Field(default=None, index=True) class Hero(HeroBase, table=True): id: Union[int, None] = Field(default=None, primary_key=True) secret_name: str class HeroPublic(HeroBase):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Oct 09 19:44:42 UTC 2024 - 2.6K bytes - Viewed (0) -
tests/test_union_forms.py
from typing import Annotated, Union from fastapi import FastAPI, Form from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() class UserForm(BaseModel): name: str email: str class CompanyForm(BaseModel): company_name: str industry: str @app.post("/form-union/") def post_union_form(data: Annotated[Union[UserForm, CompanyForm], Form()]):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 5.2K bytes - Viewed (0) -
docs/zh/docs/tutorial/body-nested-models.md
## 具有子类型的 List 字段 但是 Python 有一种特定的方法来声明具有子类型的列表: ### 从 typing 导入 `List` 首先,从 Python 的标准库 `typing` 模块中导入 `List`: {* ../../docs_src/body_nested_models/tutorial002.py hl[1] *} ### 声明具有子类型的 List 要声明具有子类型的类型,例如 `list`、`dict`、`tuple`: * 从 `typing` 模块导入它们 * 使用方括号 `[` 和 `]` 将子类型作为「类型参数」传入 ```Python from typing import List my_list: List[str] ``` 这完全是用于类型声明的标准 Python 语法。Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 18 02:25:44 UTC 2024 - 6.7K bytes - Viewed (0) -
docs_src/custom_request_and_route/tutorial001_an_py39.py
import gzip from typing import Annotated, Callable from fastapi import Body, FastAPI, Request, Response from fastapi.routing import APIRoute class GzipRequest(Request): async def body(self) -> bytes: if not hasattr(self, "_body"): body = await super().body() if "gzip" in self.headers.getlist("Content-Encoding"): body = gzip.decompress(body) self._body = body
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 10 08:55:32 UTC 2025 - 988 bytes - Viewed (0)