19 lines
615 B
Python
19 lines
615 B
Python
from fastapi import FastAPI, Query, HTTPException
|
|
from fastapi.responses import JSONResponse
|
|
import uvicorn
|
|
from downloader import download_song
|
|
from config import settings
|
|
|
|
app = FastAPI(title="Tunedrop")
|
|
|
|
@app.get("/download")
|
|
def download(query: str = Query(..., description="Song name or YouTube search term")):
|
|
try:
|
|
result = download_song(query)
|
|
return JSONResponse(content={"status": "success", **result})
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
|