- Sort Score
- Result 10 results
- Languages All
Results 421 - 430 of 1,127 for def2 (0.03 sec)
-
docs_src/websockets/tutorial001.py
input.value = '' event.preventDefault() } </script> </body> </html> """ @app.get("/") async def get(): return HTMLResponse(html) @app.websocket("/ws") async def websocket_endpoint(websocket: WebSocket): await websocket.accept() while True: data = await websocket.receive_text()
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Mar 26 19:09:53 UTC 2020 - 1.4K bytes - Viewed (0) -
tests/test_union_inherited_body.py
@app.post("/items/") def save_union_different_body(item: Union[ExtendedItem, Item]): return {"item": item} client = TestClient(app) def test_post_extended_item(): response = client.post("/items/", json={"name": "Foo", "age": 5}) assert response.status_code == 200, response.text assert response.json() == {"item": {"name": "Foo", "age": 5}} def test_post_item():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 5.2K bytes - Viewed (0) -
docs_src/dependencies/tutorial002_py310.py
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}] class CommonQueryParams: def __init__(self, q: str | None = None, skip: int = 0, limit: int = 100): self.q = q self.skip = skip self.limit = limit @app.get("/items/") async def read_items(commons: CommonQueryParams = Depends(CommonQueryParams)): response = {} if commons.q:
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jan 07 14:11:31 UTC 2022 - 624 bytes - Viewed (0) -
docs_src/response_model/tutorial001.py
price: float tax: Union[float, None] = None tags: List[str] = [] @app.post("/items/", response_model=Item) async def create_item(item: Item) -> Any: return item @app.get("/items/", response_model=List[Item]) async def read_items() -> Any: return [ {"name": "Portal Gun", "price": 42.0}, {"name": "Plumbus", "price": 32.0},
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Jan 07 13:45:48 UTC 2023 - 562 bytes - Viewed (0) -
docs_src/dependencies/tutorial004_py310.py
fake_items_db = [{"item_name": "Foo"}, {"item_name": "Bar"}, {"item_name": "Baz"}] class CommonQueryParams: def __init__(self, q: str | None = None, skip: int = 0, limit: int = 100): self.q = q self.skip = skip self.limit = limit @app.get("/items/") async def read_items(commons: CommonQueryParams = Depends()): response = {} if commons.q: response.update({"q": commons.q})
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jan 07 14:11:31 UTC 2022 - 607 bytes - Viewed (0) -
tests/test_tutorial/test_custom_response/test_tutorial001b.py
from fastapi.testclient import TestClient from docs_src.custom_response.tutorial001b import app client = TestClient(app) def test_get_custom_response(): response = client.get("/items/") assert response.status_code == 200, response.text assert response.json() == [{"item_id": "Foo"}] def test_openapi_schema(): response = client.get("/openapi.json") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 1K bytes - Viewed (0) -
tests/test_tutorial/test_custom_response/test_tutorial005.py
from fastapi.testclient import TestClient from docs_src.custom_response.tutorial005 import app client = TestClient(app) def test_get(): response = client.get("/") assert response.status_code == 200, response.text assert response.text == "Hello World" def test_openapi_schema(): response = client.get("/openapi.json") assert response.status_code == 200, response.text assert response.json() == {
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 980 bytes - Viewed (0) -
tests/test_tutorial/test_custom_request_and_route/test_tutorial001.py
from docs_src.custom_request_and_route.tutorial001 import app @app.get("/check-class") async def check_gzip_request(request: Request): return {"request_class": type(request).__name__} client = TestClient(app) @pytest.mark.parametrize("compress", [True, False]) def test_gzip_request(compress): n = 1000 headers = {} body = [1] * n data = json.dumps(body).encode()
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Nov 13 14:26:09 UTC 2022 - 886 bytes - Viewed (0) -
docs_src/request_files/tutorial001_an_py39.py
from typing import Annotated from fastapi import FastAPI, File, UploadFile app = FastAPI() @app.post("/files/") async def create_file(file: Annotated[bytes, File()]): return {"file_size": len(file)} @app.post("/uploadfile/") async def create_upload_file(file: UploadFile):
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 322 bytes - Viewed (0) -
docs_src/settings/app02/main.py
from functools import lru_cache from fastapi import Depends, FastAPI from .config import Settings app = FastAPI() @lru_cache def get_settings(): return Settings() @app.get("/info") async def info(settings: Settings = Depends(get_settings)): return { "app_name": settings.app_name, "admin_email": settings.admin_email, "items_per_user": settings.items_per_user,
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Oct 24 20:26:06 UTC 2023 - 406 bytes - Viewed (0)