File size: 545 Bytes
24cb476
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""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'},
    )