dragxd commited on
Commit
7451bec
·
verified ·
1 Parent(s): 13e1927

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -2,13 +2,19 @@ from fastapi import FastAPI, HTTPException
2
  from fastapi.responses import RedirectResponse
3
  import subprocess
4
 
5
- app = FastAPI()
 
 
 
 
 
 
6
 
7
- @app.get("/")
8
  async def root():
9
  return {"status": "FastAPI working", "message": "YT-DLP backend ready"}
10
 
11
- @app.get("/stream/{vidid}")
12
  async def stream_audio(vidid: str):
13
  try:
14
  result = subprocess.run(
@@ -20,4 +26,4 @@ async def stream_audio(vidid: str):
20
  raise HTTPException(status_code=404, detail="No audio URL found.")
21
  return RedirectResponse(url)
22
  except Exception as e:
23
- raise HTTPException(status_code=500, detail=str(e))
 
2
  from fastapi.responses import RedirectResponse
3
  import subprocess
4
 
5
+ app = FastAPI(
6
+ title="YouTube Audio Streamer",
7
+ description="Stream best audio of a YouTube video using yt-dlp.",
8
+ version="1.0.0",
9
+ docs_url="/docs",
10
+ redoc_url="/redoc"
11
+ )
12
 
13
+ @app.get("/", tags=["Health"])
14
  async def root():
15
  return {"status": "FastAPI working", "message": "YT-DLP backend ready"}
16
 
17
+ @app.get("/stream/{vidid}", tags=["Stream"])
18
  async def stream_audio(vidid: str):
19
  try:
20
  result = subprocess.run(
 
26
  raise HTTPException(status_code=404, detail="No audio URL found.")
27
  return RedirectResponse(url)
28
  except Exception as e:
29
+ raise HTTPException(status_code=500, detail=f"Error: {str(e)}")