Update app.py
Browse files
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 |
-
|
| 8 |
-
|
| 9 |
-
|
| 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")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|