Search Options

Results per page
Sort
Preferred Languages
Advance

Results 751 - 760 of 1,127 for def2 (0.02 sec)

  1. docs_src/response_cookies/tutorial001.py

    from fastapi import FastAPI
    from fastapi.responses import JSONResponse
    
    app = FastAPI()
    
    
    @app.post("/cookie/")
    def create_cookie():
        content = {"message": "Come to the dark side, we have cookies"}
        response = JSONResponse(content=content)
        response.set_cookie(key="fakesession", value="fake-cookie-session-value")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 344 bytes
    - Viewed (0)
  2. tests/test_modules_same_name_body/app/b.py

    from fastapi import APIRouter, Body
    
    router = APIRouter()
    
    
    @router.post("/compute/")
    def compute(a: int = Body(), b: str = Body()):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 161 bytes
    - Viewed (0)
  3. docs_src/additional_status_codes/tutorial001_an_py39.py

    from fastapi.responses import JSONResponse
    
    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[Union[str, None], Body()] = None,
        size: Annotated[Union[int, None], Body()] = None,
    ):
        if item_id in items:
            item = items[item_id]
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 705 bytes
    - Viewed (0)
  4. docs_src/body_fields/tutorial001_an.py

        )
        price: float = Field(gt=0, description="The price must be greater than zero")
        tax: Union[float, None] = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(item_id: int, item: Annotated[Item, Body(embed=True)]):
        results = {"item_id": item_id, "item": item}
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 611 bytes
    - Viewed (0)
  5. docs_src/body_multiple_params/tutorial001.py

    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(
        *,
        item_id: int = Path(title="The ID of the item to get", ge=0, le=1000),
        q: Union[str, None] = None,
        item: Union[Item, None] = None,
    ):
        results = {"item_id": item_id}
        if q:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 596 bytes
    - Viewed (0)
  6. docs_src/custom_response/tutorial006b.py

    from fastapi import FastAPI
    from fastapi.responses import RedirectResponse
    
    app = FastAPI()
    
    
    @app.get("/fastapi", response_class=RedirectResponse)
    async def redirect_fastapi():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Jul 03 19:51:28 UTC 2021
    - 220 bytes
    - Viewed (0)
  7. docs_src/custom_response/tutorial009.py

    from fastapi import FastAPI
    from fastapi.responses import FileResponse
    
    some_file_path = "large-video-file.mp4"
    app = FastAPI()
    
    
    @app.get("/")
    async def main():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 202 bytes
    - Viewed (0)
  8. docs_src/behind_a_proxy/tutorial003.py

            {"url": "https://prod.example.com", "description": "Production environment"},
        ],
        root_path="/api/v1",
    )
    
    
    @app.get("/app")
    def read_main(request: Request):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 10 17:28:18 UTC 2020
    - 405 bytes
    - Viewed (0)
  9. docs_src/cookie_param_models/tutorial001_an_py39.py

    app = FastAPI()
    
    
    class Cookies(BaseModel):
        session_id: str
        fatebook_tracker: Union[str, None] = None
        googall_tracker: Union[str, None] = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Annotated[Cookies, Cookie()]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 362 bytes
    - Viewed (0)
  10. docs_src/query_params_str_validations/tutorial003.py

    from typing import Union
    
    from fastapi import FastAPI, Query
    
    app = FastAPI()
    
    
    @app.get("/items/")
    async def read_items(
        q: Union[str, None] = Query(default=None, min_length=3, max_length=50),
    ):
        results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
        if q:
            results.update({"q": q})
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Mar 26 16:56:53 UTC 2024
    - 329 bytes
    - Viewed (0)
Back to top