Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 36 for on_event (0.25 sec)

  1. tests/test_router_events.py

        def app_shutdown() -> None:
            state.app_shutdown = True
    
        router = APIRouter()
    
        @router.on_event("startup")
        def router_startup() -> None:
            state.router_startup = True
    
        @router.on_event("shutdown")
        def router_shutdown() -> None:
            state.router_shutdown = True
    
        sub_router = APIRouter()
    
        @sub_router.on_event("startup")
        def sub_router_startup() -> None:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Oct 18 12:36:40 GMT 2023
    - 3.2K bytes
    - Viewed (0)
  2. docs_src/async_sql_databases/tutorial001.py

        text: str
        completed: bool
    
    
    class Note(BaseModel):
        id: int
        text: str
        completed: bool
    
    
    app = FastAPI()
    
    
    @app.on_event("startup")
    async def startup():
        await database.connect()
    
    
    @app.on_event("shutdown")
    async def shutdown():
        await database.disconnect()
    
    
    @app.get("/notes/", response_model=List[Note])
    async def read_notes():
        query = notes.select()
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 1.4K bytes
    - Viewed (0)
  3. docs_src/events/tutorial001.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):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 283 bytes
    - Viewed (0)
  4. docs/en/docs/reference/apirouter.md

                - include_router
                - get
                - put
                - post
                - delete
                - options
                - head
                - patch
                - trace
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 524 bytes
    - Viewed (0)
  5. docs/de/docs/reference/apirouter.md

                - include_router
                - get
                - put
                - post
                - delete
                - options
                - head
                - patch
                - trace
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 18:16:35 GMT 2024
    - 538 bytes
    - Viewed (0)
  6. docs/de/docs/reference/fastapi.md

                - include_router
                - get
                - put
                - post
                - delete
                - options
                - head
                - patch
                - trace
                - on_event
                - middleware
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Feb 18 12:19:32 GMT 2024
    - 715 bytes
    - Viewed (0)
  7. docs/en/docs/reference/fastapi.md

                - include_router
                - get
                - put
                - post
                - delete
                - options
                - head
                - patch
                - trace
                - on_event
                - middleware
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 701 bytes
    - Viewed (0)
  8. docs_src/app_testing/tutorial003.py

    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    
    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):
        return items[item_id]
    
    
    def test_read_items():
        with TestClient(app) as client:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 528 bytes
    - Viewed (0)
  9. docs_src/events/tutorial002.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.on_event("shutdown")
    def shutdown_event():
        with open("log.txt", mode="a") as log:
            log.write("Application shutdown")
    
    
    @app.get("/items/")
    async def read_items():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 255 bytes
    - Viewed (0)
  10. docs/en/docs/advanced/async-tests.md

    href="https://stackoverflow.com/questions/41584243/runtimeerror-task-attached-to-a-different-loop" class="external-link" target="_blank">MongoDB's MotorClient</a>) Remember to instantiate objects that need an event loop only within async functions, e.g. an `'@app.on_event("startup")` callback....
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Jan 13 12:07:15 GMT 2024
    - 3.9K bytes
    - Viewed (0)
Back to top