- Sort Score
- Result 10 results
- Languages All
Results 1 - 4 of 4 for send_json (0.1 sec)
-
tests/test_http_connection_injection.py
return value @app.websocket("/ws") async def get_value_by_ws( websocket: WebSocket, value: int = Depends(extract_value_from_http_connection) ): 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
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Aug 09 13:56:41 UTC 2020 - 972 bytes - Viewed (0) -
docs_src/app_testing/tutorial002.py
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) response = client.get("/") assert response.status_code == 200
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Wed Feb 08 10:23:07 UTC 2023 - 757 bytes - Viewed (0) -
docs/en/docs/reference/websockets.md
- receive_bytes - receive_json - iter_text - iter_bytes - iter_json - send_text - send_bytes - send_json - close When a client disconnects, a `WebSocketDisconnect` exception is raised, you can catch it. You can import it directly form `fastapi`: ```python from fastapi import WebSocketDisconnect
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Aug 06 04:48:30 UTC 2024 - 1.7K bytes - Viewed (0) -
tests/test_route_scope.py
@app.websocket("/items/{item_id}") async def websocket_item(item_id: str, websocket: WebSocket): route: APIWebSocketRoute = websocket.scope["route"] await websocket.accept() await websocket.send_json({"item_id": item_id, "path": route.path}) client = TestClient(app) def test_get(): response = client.get("/users/rick") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Wed Feb 08 10:23:07 UTC 2023 - 1.5K bytes - Viewed (0)