- Sort Score
- Result 10 results
- Languages All
Results 401 - 410 of 1,074 for Str (0.03 sec)
-
docs_src/dependencies/tutorial008c_an.py
def get_username(): try: yield "Rick" except InternalError: print("Oops, we didn't raise again, Britney π±") @app.get("/items/{item_id}") def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): if item_id == "portal-gun": raise InternalError( f"The portal gun is too dangerous to be owned by {username}" ) if item_id != "plumbus":
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Feb 24 23:06:37 UTC 2024 - 710 bytes - Viewed (0) -
docs_src/dependencies/tutorial012.py
from fastapi import Depends, FastAPI, Header, HTTPException async def verify_token(x_token: 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: str = Header()): if x_key != "fake-super-secret-key": raise HTTPException(status_code=400, detail="X-Key header invalid") return x_key
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 696 bytes - Viewed (0) -
docs_src/path_operation_advanced_configuration/tutorial007_pv1.py
from typing import List import yaml from fastapi import FastAPI, HTTPException, Request from pydantic import BaseModel, ValidationError app = FastAPI() class Item(BaseModel): name: str tags: List[str] @app.post( "/items/", openapi_extra={ "requestBody": { "content": {"application/x-yaml": {"schema": Item.schema()}}, "required": True, }, }, )
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 789 bytes - Viewed (0) -
docs_src/additional_status_codes/tutorial001.py
app = FastAPI() items = {"foo": {"name": "Fighters", "size": 6}, "bar": {"name": "Tenders", "size": 3}} @app.put("/items/{item_id}") async def upsert_item( item_id: str, name: Union[str, None] = Body(default=None), size: Union[int, None] = Body(default=None), ): if item_id in items: item = items[item_id] item["name"] = name item["size"] = size
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 684 bytes - Viewed (0) -
docs_src/additional_status_codes/tutorial001_an_py310.py
app = FastAPI() items = {"foo": {"name": "Fighters", "size": 6}, "bar": {"name": "Tenders", "size": 3}} @app.put("/items/{item_id}") async def upsert_item( item_id: str, name: Annotated[str | None, Body()] = None, size: Annotated[int | None, Body()] = None, ): if item_id in items: item = items[item_id] item["name"] = name item["size"] = size
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 686 bytes - Viewed (0) -
tests/test_router_redirect_slashes.py
from fastapi import APIRouter, FastAPI from fastapi.testclient import TestClient def test_redirect_slashes_enabled(): app = FastAPI() router = APIRouter() @router.get("/hello/") def hello_page() -> str: return "Hello, World!" app.include_router(router) client = TestClient(app) response = client.get("/hello/", follow_redirects=False) assert response.status_code == 200
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Jun 22 10:37:50 UTC 2023 - 974 bytes - Viewed (0) -
docs/uk/docs/python-types.md
```Python hl_lines="1 4" {!../../docs_src/python_types/tutorial009.py!} ``` ΠΠΈΠΊΠΎΡΠΈΡΡΠ°Π½Π½Ρ `Optional[str]` Π·Π°ΠΌΡΡΡΡ ΠΏΡΠΎΡΡΠΎ `str` Π΄ΠΎΠ·Π²ΠΎΠ»ΠΈΡΡ ΡΠ΅Π΄Π°ΠΊΡΠΎΡΡ Π΄ΠΎΠΏΠΎΠΌΠΎΠ³ΡΠΈ Π²Π°ΠΌ Π²ΠΈΡΠ²ΠΈΡΠΈ ΠΏΠΎΠΌΠΈΠ»ΠΊΠΈ, ΠΊΠΎΠ»ΠΈ Π²ΠΈ ΠΌΠΎΠ³Π»ΠΈ Π± Π²Π²Π°ΠΆΠ°ΡΠΈ, ΡΠΎ Π·Π½Π°ΡΠ΅Π½Π½ΡΠΌ Π·Π°Π²ΠΆΠ΄ΠΈ Ρ `str`, Ρ ΠΎΡΠ° Π½Π°ΡΠΏΡΠ°Π²Π΄Ρ Π²ΠΎΠ½ΠΎ ΡΠ°ΠΊΠΎΠΆ ΠΌΠΎΠΆΠ΅ Π±ΡΡΠΈ `None`. `Optional[Something]` Π½Π°ΡΠΏΡΠ°Π²Π΄Ρ Ρ ΡΠΊΠΎΡΠΎΡΠ΅Π½Π½ΡΠΌ Π΄Π»Ρ `Union[Something, None]`, Π²ΠΎΠ½ΠΈ Π΅ΠΊΠ²ΡΠ²Π°Π»Π΅Π½ΡΠ½Ρ. Π¦Π΅ ΡΠ°ΠΊΠΎΠΆ ΠΎΠ·Π½Π°ΡΠ°Ρ, ΡΠΎ Π² Python 3.10 Π²ΠΈ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π²ΠΈΠΊΠΎΡΠΈΡΡΠΎΠ²ΡΠ²Π°ΡΠΈ `Something | None`:
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 19.5K bytes - Viewed (0) -
tests/test_response_class_no_mediatype.py
from pydantic import BaseModel app = FastAPI() class JsonApiResponse(JSONResponse): media_type = "application/vnd.api+json" class Error(BaseModel): status: str title: str class JsonApiError(BaseModel): errors: typing.List[Error] @app.get( "/a", response_class=Response, responses={500: {"description": "Error", "model": JsonApiError}}, )
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 3.3K bytes - Viewed (0) -
docs_src/dependencies/tutorial008b_an_py39.py
def get_username(): try: yield "Rick" except OwnerError as e: raise HTTPException(status_code=400, detail=f"Owner error: {e}") @app.get("/items/{item_id}") def get_item(item_id: str, username: Annotated[str, Depends(get_username)]): if item_id not in data: raise HTTPException(status_code=404, detail="Item not found") item = data[item_id] if item["owner"] != username:
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Dec 26 20:37:34 UTC 2023 - 775 bytes - Viewed (0) -
docs_src/sql_databases/tutorial001.py
from sqlmodel import Field, Session, SQLModel, create_engine, select class Hero(SQLModel, table=True): id: Union[int, None] = Field(default=None, primary_key=True) name: str = Field(index=True) age: Union[int, None] = Field(default=None, index=True) secret_name: str sqlite_file_name = "database.db" sqlite_url = f"sqlite:///{sqlite_file_name}" connect_args = {"check_same_thread": False}
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Wed Oct 09 19:44:42 UTC 2024 - 1.8K bytes - Viewed (0)