Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 91 - 100 of 1,038 for Async (0.07 seconds)

  1. docs_src/request_files/tutorial001_02_an_py310.py

    from fastapi import FastAPI, File, UploadFile
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_file(file: Annotated[bytes | None, File()] = None):
        if not file:
            return {"message": "No file sent"}
        else:
            return {"file_size": len(file)}
    
    
    @app.post("/uploadfile/")
    async def create_upload_file(file: UploadFile | None = None):
        if not file:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 505 bytes
    - Click Count (0)
  2. docs_src/response_model/tutorial001_01_py310.py

    class Item(BaseModel):
        name: str
        description: str | None = None
        price: float
        tax: float | None = None
        tags: list[str] = []
    
    
    @app.post("/items/")
    async def create_item(item: Item) -> Item:
        return item
    
    
    @app.get("/items/")
    async def read_items() -> list[Item]:
        return [
            Item(name="Portal Gun", price=42.0),
            Item(name="Plumbus", price=32.0),
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Jan 07 13:45:48 GMT 2023
    - 469 bytes
    - Click Count (0)
  3. docs_src/metadata/tutorial004_py310.py

            },
        },
    ]
    
    app = FastAPI(openapi_tags=tags_metadata)
    
    
    @app.get("/users/", tags=["users"])
    async def get_users():
        return [{"name": "Harry"}, {"name": "Ron"}]
    
    
    @app.get("/items/", tags=["items"])
    async def get_items():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 693 bytes
    - Click Count (0)
  4. docs/en/docs/tutorial/request-files.md

        * This is especially useful if you run `await myfile.read()` once and then need to read the contents again.
    * `close()`: Closes the file.
    
    As all these methods are `async` methods, you need to "await" them.
    
    For example, inside of an `async` *path operation function* you can get the contents with:
    
    ```Python
    contents = await myfile.read()
    ```
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 7K bytes
    - Click Count (0)
  5. docs_src/path_params/tutorial003_py310.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/users/me")
    async def read_user_me():
        return {"user_id": "the current user"}
    
    
    @app.get("/users/{user_id}")
    async def read_user(user_id: str):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 236 bytes
    - Click Count (0)
  6. docs_src/async_tests/app_a_py310/test_main.py

    import pytest
    from httpx import ASGITransport, AsyncClient
    
    from .main import app
    
    
    @pytest.mark.anyio
    async def test_root():
        async with AsyncClient(
            transport=ASGITransport(app=app), base_url="http://test"
        ) as ac:
            response = await ac.get("/")
        assert response.status_code == 200
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 360 bytes
    - Click Count (0)
  7. docs_src/events/tutorial001_py310.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    items = {}
    
    
    @app.on_event("startup")
    async def startup_event():
        items["foo"] = {"name": "Fighters"}
        items["bar"] = {"name": "Tenders"}
    
    
    @app.get("/items/{item_id}")
    async def read_items(item_id: str):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 283 bytes
    - Click Count (0)
  8. docs_src/path_operation_configuration/tutorial002b_py310.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    class Tags(Enum):
        items = "items"
        users = "users"
    
    
    @app.get("/items/", tags=[Tags.items])
    async def get_items():
        return ["Portal gun", "Plumbus"]
    
    
    @app.get("/users/", tags=[Tags.users])
    async def read_users():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 323 bytes
    - Click Count (0)
  9. docs_src/request_files/tutorial001_an_py310.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):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 322 bytes
    - Click Count (0)
  10. docs_src/websockets_/tutorial002_py310.py

                    input.value = ''
                    event.preventDefault()
                }
            </script>
        </body>
    </html>
    """
    
    
    @app.get("/")
    async def get():
        return HTMLResponse(html)
    
    
    async def get_cookie_or_token(
        websocket: WebSocket,
        session: str | None = Cookie(default=None),
        token: str | None = Query(default=None),
    ):
        if session is None and token is None:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 27 12:34:37 GMT 2026
    - 2.7K bytes
    - Click Count (0)
Back to Top