Download src/controller/controller.py from the-sanket-kadam/face_authentication_v2: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/the-sanket-kadam/face_authentication_v2/resolve/main/src/controller/controller.py
- Command line
-
hf download hf://the-sanket-kadam/face_authentication_v2/src/controller/controller.py
-
curl -L -o controller.py https://huggingface.co/the-sanket-kadam/face_authentication_v2/resolve/main/src/controller/controller.py
1.06 kB
| from fastapi import WebSocket | |
| import json | |
| from src.service.service import FaceAuthenticationService | |
| class FaceAuthController: | |
| def __init__(self): | |
| self.auth_service = FaceAuthenticationService() | |
| async def handle_register(self, websocket: WebSocket): | |
| await websocket.accept() | |
| try: | |
| while True: | |
| data = await websocket.receive_text() | |
| response = self.auth_service.process_registration(json.loads(data)) | |
| await websocket.send_json(response) | |
| except Exception as e: | |
| print(f"[INFO] Register WS disconnected: {e}") | |
| async def handle_authenticate(self, websocket: WebSocket): | |
| await websocket.accept() | |
| try: | |
| while True: | |
| data = await websocket.receive_text() | |
| response = self.auth_service.process_authentication(json.loads(data)) | |
| await websocket.send_json(response) | |
| except Exception as e: | |
| print(f"[INFO] Authenticate WS disconnected: {e}") |