- Sort Score
- Result 10 results
- Languages All
Results 21 - 30 of 154 for Websockets (0.32 sec)
-
docs_src/app_testing/tutorial002.py
from fastapi.testclient import TestClient from fastapi.websockets import WebSocket app = FastAPI() @app.get("/") async def read_main(): return {"msg": "Hello World"} @app.websocket("/ws") async def websocket(websocket: WebSocket): await websocket.accept() await websocket.send_json({"msg": "Hello WebSocket"}) await websocket.close() def test_read_main(): client = TestClient(app)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Wed Feb 08 10:23:07 UTC 2023 - 757 bytes - Viewed (0) -
tests/test_http_connection_injection.py
): await websocket.accept() await websocket.send_json(value) await websocket.close() client = TestClient(app) def test_value_extracting_by_http(): response = client.get("/http") assert response.status_code == 200 assert response.json() == 42 def test_value_extracting_by_ws(): with client.websocket_connect("/ws") as websocket:
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Aug 09 13:56:41 UTC 2020 - 972 bytes - Viewed (0) -
tests/test_tutorial/test_websockets/test_tutorial002_an_py39.py
message = "Message one" websocket.send_text(message) data = websocket.receive_text() assert data == "Session cookie or query token value is: some-token" data = websocket.receive_text() assert data == f"Message text was: {message}, for item ID: bar" message = "Message two" websocket.send_text(message)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 3.9K bytes - Viewed (0) -
docs/en/docs/reference/request.md
```python from fastapi import Request ``` /// tip When you want to define dependencies that should be compatible with both HTTP and WebSockets, you can define a parameter that takes an `HTTPConnection` instead of a `Request` or a `WebSocket`. ///
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Aug 06 04:48:30 UTC 2024 - 518 bytes - Viewed (0) -
tests/test_tutorial/test_websockets/test_tutorial003_py39.py
from fastapi.testclient import TestClient from ...utils import needs_py39 @pytest.fixture(name="app") def get_app(): from docs_src.websockets.tutorial003_py39 import app return app @pytest.fixture(name="html") def get_html(): from docs_src.websockets.tutorial003_py39 import html return html @pytest.fixture(name="client") def get_client(app: FastAPI): client = TestClient(app)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 1.3K bytes - Viewed (0) -
tests/test_tutorial/test_websockets/test_tutorial002.py
message = "Message one" websocket.send_text(message) data = websocket.receive_text() assert data == "Session cookie or query token value is: some-token" data = websocket.receive_text() assert data == f"Message text was: {message}, for item ID: bar" message = "Message two" websocket.send_text(message)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Nov 13 14:26:09 UTC 2022 - 3.6K bytes - Viewed (0) -
tests/test_tutorial/test_websockets/test_tutorial003.py
from fastapi.testclient import TestClient from docs_src.websockets.tutorial003 import app, html client = TestClient(app) def test_get(): response = client.get("/") assert response.text == html 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")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Jul 29 09:26:07 UTC 2021 - 872 bytes - Viewed (0) -
tests/test_tutorial/test_websockets/test_tutorial002_py310.py
message = "Message one" websocket.send_text(message) data = websocket.receive_text() assert data == "Session cookie or query token value is: some-token" data = websocket.receive_text() assert data == f"Message text was: {message}, for item ID: bar" message = "Message two" websocket.send_text(message)
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 3.9K bytes - Viewed (0) -
fastapi/exceptions.py
from fastapi import ( Cookie, FastAPI, WebSocket, WebSocketException, status, ) app = FastAPI() @app.websocket("/items/{item_id}/ws") async def websocket_endpoint( *, websocket: WebSocket, session: Annotated[str | None, Cookie()] = None, item_id: str, ): if session is None:
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Apr 02 02:48:51 UTC 2024 - 4.9K bytes - Viewed (0) -
fastapi/exception_handlers.py
content={"detail": jsonable_encoder(exc.errors())}, ) 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())
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Jun 11 19:08:14 UTC 2023 - 1.3K bytes - Viewed (0)