Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 24 for Connection (0.44 sec)

  1. tests/test_http_connection_injection.py

    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)
    ):
        await websocket.accept()
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Aug 09 13:56:41 GMT 2020
    - 972 bytes
    - Viewed (0)
  2. docs_src/websockets/tutorial003.py

        async def broadcast(self, message: str):
            for connection in self.active_connections:
                await connection.send_text(message)
    
    
    manager = ConnectionManager()
    
    
    @app.get("/")
    async def get():
        return HTMLResponse(html)
    
    
    @app.websocket("/ws/{client_id}")
    async def websocket_endpoint(websocket: WebSocket, client_id: int):
        await manager.connect(websocket)
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Aug 09 13:52:19 GMT 2020
    - 2.5K bytes
    - Viewed (0)
  3. docs_src/websockets/tutorial003_py39.py

        async def broadcast(self, message: str):
            for connection in self.active_connections:
                await connection.send_text(message)
    
    
    manager = ConnectionManager()
    
    
    @app.get("/")
    async def get():
        return HTMLResponse(html)
    
    
    @app.websocket("/ws/{client_id}")
    async def websocket_endpoint(websocket: WebSocket, client_id: int):
        await manager.connect(websocket)
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 2.5K bytes
    - Viewed (0)
  4. docs/en/docs/how-to/sql-databases-peewee.md

    ```Python hl_lines="18-20"
    {!../../../docs_src/sql_databases_peewee/sql_app/main.py!}
    ```
    
    For the **next request**, as we will reset that context variable again in the `async` dependency `reset_db_state()` and then create a new connection in the `get_db()` dependency, that new request will have its own database state (connection, transactions, etc).
    
    !!! tip
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 16 13:23:25 GMT 2024
    - 23.6K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_websockets/test_tutorial003.py

    
    def test_websocket_handle_disconnection():
        with client.websocket_connect("/ws/1234") as connection, client.websocket_connect(
            "/ws/5678"
        ) as connection_two:
            connection.send_text("Hello from 1234")
            data1 = connection.receive_text()
            assert data1 == "You wrote: Hello from 1234"
            data2 = connection_two.receive_text()
            client1_says = "Client #1234 says: Hello from 1234"
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jul 29 09:26:07 GMT 2021
    - 872 bytes
    - Viewed (0)
  6. tests/test_tutorial/test_websockets/test_tutorial003_py39.py

    def test_websocket_handle_disconnection(client: TestClient):
        with client.websocket_connect("/ws/1234") as connection, client.websocket_connect(
            "/ws/5678"
        ) as connection_two:
            connection.send_text("Hello from 1234")
            data1 = connection.receive_text()
            assert data1 == "You wrote: Hello from 1234"
            data2 = connection_two.receive_text()
            client1_says = "Client #1234 says: Hello from 1234"
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 1.3K bytes
    - Viewed (0)
  7. docs/en/docs/advanced/websockets.md

    <img src="/img/tutorial/websockets/image03.png">
    
    You can send (and receive) many messages:
    
    <img src="/img/tutorial/websockets/image04.png">
    
    And all of them will use the same WebSocket connection.
    
    ## Using `Depends` and others
    
    In WebSocket endpoints you can import from `fastapi` and use:
    
    * `Depends`
    * `Security`
    * `Cookie`
    * `Header`
    * `Path`
    * `Query`
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu May 02 22:37:31 GMT 2024
    - 6.2K bytes
    - Viewed (0)
  8. docs/en/docs/deployment/https.md

    After this, the client and the server have an **encrypted TCP connection**, this is what TLS provides. And then they can use that connection to start the actual **HTTP communication**.
    
    And that's what **HTTPS** is, it's just plain **HTTP** inside a **secure TLS connection** instead of a pure (unencrypted) TCP connection.
    
    !!! tip
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Jan 11 16:31:18 GMT 2024
    - 12K bytes
    - Viewed (0)
  9. docs/en/docs/reference/testclient.md

    # Test Client - `TestClient`
    
    You can use the `TestClient` class to test FastAPI applications without creating an actual HTTP and socket connection, just communicating directly with the FastAPI code.
    
    Read more about it in the [FastAPI docs for Testing](https://fastapi.tiangolo.com/tutorial/testing/).
    
    You can import it directly from `fastapi.testclient`:
    
    ```python
    from fastapi.testclient import TestClient
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 450 bytes
    - Viewed (0)
  10. fastapi/dependencies/models.py

            self.security_requirements = security_schemes or []
            self.request_param_name = request_param_name
            self.websocket_param_name = websocket_param_name
            self.http_connection_param_name = http_connection_param_name
            self.response_param_name = response_param_name
            self.background_tasks_param_name = background_tasks_param_name
            self.security_scopes = security_scopes
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 2.4K bytes
    - Viewed (0)
Back to top