Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 14 of 14 for on_startup (0.11 sec)

  1. docs_src/sql_databases/tutorial002.py

        SQLModel.metadata.create_all(engine)
    
    
    def get_session():
        with Session(engine) as session:
            yield session
    
    
    app = FastAPI()
    
    
    @app.on_event("startup")
    def on_startup():
        create_db_and_tables()
    
    
    @app.post("/heroes/", response_model=HeroPublic)
    def create_hero(hero: HeroCreate, session: Session = Depends(get_session)):
        db_hero = Hero.model_validate(hero)
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 2.6K bytes
    - Viewed (0)
  2. docs_src/sql_databases/tutorial002_an_py310.py

    
    def get_session():
        with Session(engine) as session:
            yield session
    
    
    SessionDep = Annotated[Session, Depends(get_session)]
    app = FastAPI()
    
    
    @app.on_event("startup")
    def on_startup():
        create_db_and_tables()
    
    
    @app.post("/heroes/", response_model=HeroPublic)
    def create_hero(hero: HeroCreate, session: SessionDep):
        db_hero = Hero.model_validate(hero)
        session.add(db_hero)
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 2.5K bytes
    - Viewed (0)
  3. fastapi/routing.py

            ] = Default(generate_unique_id),
        ) -> None:
            super().__init__(
                routes=routes,
                redirect_slashes=redirect_slashes,
                default=default,
                on_startup=on_startup,
                on_shutdown=on_shutdown,
                lifespan=lifespan,
            )
            if prefix:
                assert prefix.startswith("/"), "A path prefix must start with '/'"
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sat Oct 12 09:44:57 UTC 2024
    - 172.1K bytes
    - Viewed (0)
  4. fastapi/applications.py

            ] = {}
            self.router: routing.APIRouter = routing.APIRouter(
                routes=routes,
                redirect_slashes=redirect_slashes,
                dependency_overrides_provider=self,
                on_startup=on_startup,
                on_shutdown=on_shutdown,
                lifespan=lifespan,
                default_response_class=default_response_class,
                dependencies=dependencies,
                callbacks=callbacks,
    Registered: Sun Oct 27 07:19:11 UTC 2024
    - Last Modified: Sat Aug 17 04:52:31 UTC 2024
    - 172.2K bytes
    - Viewed (0)
Back to top