INNER CODE UNIT · Python
WebSocketAwareStaticFiles
derisk-ai/OpenDerisk · packages/derisk-app/src/derisk_app/app.py:11
class WebSocketAwareStaticFiles(StaticFiles):
"""StaticFiles that gracefully handles WebSocket connections."""
async def __call__(self, scope, receive, send):
if scope["type"] == "websocket":
# WebSocket connections should not reach static files
# Let them fall through to 404 or other handlers
await send({"type": "websocket.close", "code": 1000})
return
await super().__call__(scope, receive, send)
from derisk._version import version
from derisk.component import SystemApp
from derisk.configs.model_config import (
STATIC_MESSAGE_IMG_PATH,
)
from derisk.util.fastapi import create_app as create_fastapi_app, replace_router