Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 6 of 6 for stats (0.12 sec)

  1. docs_src/response_change_status_code/tutorial001.py

    from fastapi import FastAPI, Response, status
    
    app = FastAPI()
    
    tasks = {"foo": "Listen to the Bar Fighters"}
    
    
    @app.put("/get-or-create-task/{task_id}", status_code=200)
    def get_or_create_task(task_id: str, response: Response):
        if task_id not in tasks:
            tasks[task_id] = "This didn't exist before"
            response.status_code = status.HTTP_201_CREATED
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 391 bytes
    - Viewed (0)
  2. docs_src/path_operation_configuration/tutorial001.py

    from typing import Set, Union
    
    from fastapi import FastAPI, status
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
        tags: Set[str] = set()
    
    
    @app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED)
    async def create_item(item: Item):
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 406 bytes
    - Viewed (0)
  3. docs_src/additional_status_codes/tutorial001.py

            item["name"] = name
            item["size"] = size
            return item
        else:
            item = {"name": name, "size": size}
            items[item_id] = item
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 684 bytes
    - Viewed (0)
  4. docs_src/dependency_testing/tutorial001.py

    def test_override_in_items():
        response = client.get("/items/")
        assert response.status_code == 200
        assert response.json() == {
            "message": "Hello Items!",
            "params": {"q": None, "skip": 5, "limit": 10},
        }
    
    
    def test_override_in_items_with_q():
        response = client.get("/items/?q=foo")
        assert response.status_code == 200
        assert response.json() == {
            "message": "Hello Items!",
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 1.5K bytes
    - Viewed (0)
  5. docs_src/response_status_code/tutorial001.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.post("/items/", status_code=201)
    async def create_item(name: str):
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 145 bytes
    - Viewed (0)
  6. docs_src/additional_responses/tutorial001.py

    @app.get("/items/{item_id}", response_model=Item, responses={404: {"model": Message}})
    async def read_item(item_id: str):
        if item_id == "foo":
            return {"id": "foo", "value": "there goes my hero"}
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Aug 26 13:32:30 GMT 2022
    - 506 bytes
    - Viewed (0)
Back to top