🎨 black
This commit is contained in:
@@ -12,7 +12,7 @@ router = APIRouter()
|
||||
file_regex = r"^[a-z0-9]{8}-[a-z0-9-]{27}--[a-z0-9-]{36}$"
|
||||
|
||||
|
||||
@router.get('/download/{file_name}')
|
||||
@router.get("/download/{file_name}")
|
||||
async def download_file(file_name: str):
|
||||
if not re.match(file_regex, file_name):
|
||||
raise HTTPException(status_code=400, detail="Invalid file name")
|
||||
@@ -24,5 +24,8 @@ async def download_file(file_name: str):
|
||||
def iter_file():
|
||||
yield from download
|
||||
|
||||
return StreamingResponse(iter_file(), media_type='image/*',
|
||||
headers={"Cache-Control": "public, immutable, max-age=31536000"})
|
||||
return StreamingResponse(
|
||||
iter_file(),
|
||||
media_type="image/*",
|
||||
headers={"Cache-Control": "public, immutable, max-age=31536000"},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user