ZHIWEI666 commited on
Commit
aaa01f2
·
verified ·
1 Parent(s): b7b932b

Upload api_music.py

Browse files
Files changed (1) hide show
  1. api_music.py +3 -2
api_music.py CHANGED
@@ -9,7 +9,7 @@ import shutil
9
  from typing import List, Optional
10
  from datetime import datetime
11
  from fastapi import APIRouter, UploadFile, File, Form
12
- from fastapi.responses import FileResponse
13
  from huggingface_hub import hf_hub_download
14
  from pydantic import BaseModel
15
  from mutagen import File as MutagenFile
@@ -134,7 +134,8 @@ async def download_file(filename: str):
134
  try:
135
  path = await asyncio.to_thread(hf_hub_download, repo_id=REPO_ID, filename=filename, repo_type="dataset", token=TOKEN)
136
  return FileResponse(path, filename=os.path.basename(filename))
137
- except Exception as e: return {"status": "error", "message": str(e)}
 
138
 
139
  @router.post("/api/hub/interactions")
140
  async def get_interactions(req: BasicReq):
 
9
  from typing import List, Optional
10
  from datetime import datetime
11
  from fastapi import APIRouter, UploadFile, File, Form
12
+ from fastapi.responses import FileResponse, JSONResponse
13
  from huggingface_hub import hf_hub_download
14
  from pydantic import BaseModel
15
  from mutagen import File as MutagenFile
 
134
  try:
135
  path = await asyncio.to_thread(hf_hub_download, repo_id=REPO_ID, filename=filename, repo_type="dataset", token=TOKEN)
136
  return FileResponse(path, filename=os.path.basename(filename))
137
+ except Exception as e:
138
+ return JSONResponse(status_code=404, content={"status": "error", "message": str(e)})
139
 
140
  @router.post("/api/hub/interactions")
141
  async def get_interactions(req: BasicReq):