Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 67 for clone (0.14 sec)

  1. docs_src/dependencies/tutorial008_an.py

    
    async def dependency_a():
        dep_a = generate_dep_a()
        try:
            yield dep_a
        finally:
            dep_a.close()
    
    
    async def dependency_b(dep_a: Annotated[DepA, Depends(dependency_a)]):
        dep_b = generate_dep_b()
        try:
            yield dep_b
        finally:
            dep_b.close(dep_a)
    
    
    async def dependency_c(dep_b: Annotated[DepB, Depends(dependency_b)]):
        dep_c = generate_dep_c()
        try:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 531 bytes
    - Viewed (0)
  2. scripts/playwright/separate_openapi_schemas/image01.py

        page.get_by_role("tab", name="Schema").first.click()
        page.screenshot(
            path="docs/en/docs/img/tutorial/separate-openapi-schemas/image01.png"
        )
    
        # ---------------------
        context.close()
        browser.close()
    
    
    process = subprocess.Popen(
        ["uvicorn", "docs_src.separate_openapi_schemas.tutorial001:app"]
    )
    try:
        with sync_playwright() as playwright:
            run(playwright)
    finally:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Aug 25 19:10:22 GMT 2023
    - 819 bytes
    - Viewed (0)
  3. docs_src/response_headers/tutorial001.py

    from fastapi import FastAPI
    from fastapi.responses import JSONResponse
    
    app = FastAPI()
    
    
    @app.get("/headers/")
    def get_headers():
        content = {"message": "Hello World"}
        headers = {"X-Cat-Dog": "alone in the world", "Content-Language": "en-US"}
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 309 bytes
    - Viewed (0)
  4. tests/test_tutorial/test_response_headers/test_tutorial002.py

    def test_path_operation():
        response = client.get("/headers-and-object/")
        assert response.status_code == 200, response.text
        assert response.json() == {"message": "Hello World"}
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jul 09 18:06:12 GMT 2020
    - 378 bytes
    - Viewed (0)
  5. tests/test_tutorial/test_response_headers/test_tutorial001.py

    
    def test_path_operation():
        response = client.get("/headers/")
        assert response.status_code == 200, response.text
        assert response.json() == {"message": "Hello World"}
        assert response.headers["X-Cat-Dog"] == "alone in the world"
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jul 09 18:06:12 GMT 2020
    - 426 bytes
    - Viewed (0)
  6. fastapi/exception_handlers.py

        )
    
    
    async def websocket_request_validation_exception_handler(
        websocket: WebSocket, exc: WebSocketRequestValidationError
    ) -> None:
        await websocket.close(
            code=WS_1008_POLICY_VIOLATION, reason=jsonable_encoder(exc.errors())
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Jun 11 19:08:14 GMT 2023
    - 1.3K bytes
    - Viewed (0)
  7. docs_src/sql_databases/sql_app/tests/test_sql_app.py

    
    Base.metadata.create_all(bind=engine)
    
    
    def override_get_db():
        try:
            db = TestingSessionLocal()
            yield db
        finally:
            db.close()
    
    
    app.dependency_overrides[get_db] = override_get_db
    
    client = TestClient(app)
    
    
    def test_create_user():
        response = client.post(
            "/users/",
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jun 22 11:20:12 GMT 2023
    - 1.2K bytes
    - Viewed (0)
  8. docs_src/sql_databases/sql_app_py310/main.py

    models.Base.metadata.create_all(bind=engine)
    
    app = FastAPI()
    
    
    # Dependency
    def get_db():
        db = SessionLocal()
        try:
            yield db
        finally:
            db.close()
    
    
    @app.post("/users/", response_model=schemas.User)
    def create_user(user: schemas.UserCreate, db: Session = Depends(get_db)):
        db_user = crud.get_user_by_email(db, email=user.email)
        if db_user:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 1.6K bytes
    - Viewed (0)
  9. docs/en/docs/tutorial/sql-databases.md

    We need to have an independent database session/connection (`SessionLocal`) per request, use the same session through all the request and then close it after the request is finished.
    
    And then a new session will be created for the next request.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 29.6K bytes
    - Viewed (0)
  10. docs/en/docs/tutorial/dependencies/dependencies-with-yield.md

        would be valid to use as a **FastAPI** dependency.
    
        In fact, FastAPI uses those two decorators internally.
    
    ## A database dependency with `yield`
    
    For example, you could use this to create a database session and close it after finishing.
    
    Only the code prior to and including the `yield` statement is executed before creating a response:
    
    ```Python hl_lines="2-4"
    {!../../../docs_src/dependencies/tutorial007.py!}
    ```
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 14.1K bytes
    - Viewed (0)
Back to top