-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathapi.py
More file actions
31 lines (22 loc) · 792 Bytes
/
api.py
File metadata and controls
31 lines (22 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from music import MusicService
app = FastAPI()
class ProcessAudioRequest(BaseModel):
file_path: str
output_directory_path: str
@app.post("/process-audio")
async def process_audio(request: ProcessAudioRequest):
"""
Обрабатывает POST-запрос для обработки директории.
"""
file_path = request.file_path
try:
music_service = MusicService()
music_service.convert_files_to_mp3(file_path)
return {"message": "Directory processed successfully"}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)