acra-backend / code /device_engine.py
Zeref8425's picture
feat(offline): authenticate device engine downloads
24cb476
Raw History Blame Contribute Delete
545 Bytes
"""Authenticated transfer of the installed inference artifact."""
from pathlib import Path
from fastapi import HTTPException
from fastapi.responses import FileResponse
def engine_response(model_path):
if not model_path or not Path(model_path).is_file():
raise HTTPException(503, detail='The device engine is unavailable. Try again later.')
return FileResponse(
model_path,
media_type='application/octet-stream',
headers={'Cache-Control': 'private, no-store', 'X-Content-Type-Options': 'nosniff'},
)