MFF212 commited on
Commit
f700a31
·
verified ·
1 Parent(s): 40faafc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -12
app.py CHANGED
@@ -1,17 +1,8 @@
1
  from fastapi import FastAPI
2
  from fastapi.responses import FileResponse
3
- import os
4
 
5
  app = FastAPI()
6
 
7
- AUDIO_DIR = "sample.mp3"
8
-
9
- @app.get("/audio/{filename}")
10
- def get_audio(filename: str):
11
- file_path = os.path.join(AUDIO_DIR, filename)
12
-
13
- if not os.path.exists(file_path):
14
- return {"error": "File not found"}
15
-
16
- # FastAPI automatically sets correct header based on file type
17
- return FileResponse(file_path, media_type="audio/mpeg")
 
1
  from fastapi import FastAPI
2
  from fastapi.responses import FileResponse
 
3
 
4
  app = FastAPI()
5
 
6
+ @app.get("/audio")
7
+ def get_audio():
8
+ return FileResponse("sample.mp3", media_type="audio/mpeg")