File size: 603 Bytes
093a866
 
c2eed51
093a866
 
 
 
 
 
 
 
 
 
 
 
 
 
ba9fae4
c2eed51
ba9fae4
 
 
 
 
 
 
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
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fetchYoutubeSubtitle import fetchSubtitle, fetchSubtitleUrls

app = FastAPI()

@app.get("/")
def read_root():
    return {"Hello": "World!"}


@app.get("/json")
def read_json():
    return JSONResponse(content={"Hello": "World!"})


@app.get("/subtitle/")
async def get_subtitle(url: str):
    subtitle = await fetchSubtitle(url)
    return JSONResponse(content=subtitle)


@app.get("/subtitle-urls/")
async def get_subtitleUrls(url: str):
    subtitles = await fetchSubtitleUrls(url)
    return JSONResponse(content=subtitles)