Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for get_value_by_http (0.35 sec)

  1. tests/test_http_connection_injection.py

    app = FastAPI()
    app.state.value = 42
    
    
    async def extract_value_from_http_connection(conn: HTTPConnection):
        return conn.app.state.value
    
    
    @app.get("/http")
    async def get_value_by_http(value: int = Depends(extract_value_from_http_connection)):
        return value
    
    
    @app.websocket("/ws")
    async def get_value_by_ws(
        websocket: WebSocket, value: int = Depends(extract_value_from_http_connection)
    ):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Aug 09 13:56:41 GMT 2020
    - 972 bytes
    - Viewed (0)
Back to top