-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (25 loc) · 987 Bytes
/
main.py
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
32
33
34
35
36
37
38
from graph import YandexMusicGraph
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse, HTMLResponse
from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles
import uvicorn
app = FastAPI()
templates = Jinja2Templates(directory="templates")
app.mount("/static", StaticFiles(directory="static"), name="static")
graph = YandexMusicGraph()
@app.get("/")
async def home(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
@app.get("/search_artist")
async def search_artist(artist: str):
return graph.search_artist(artist)
@app.get("/search_path/")
async def search_path(artist_1: str, artist_2: str):
print(f"Artist 1: {artist_1}, Artist 2: {artist_2}")
result = graph.search_collaborations(artist_1, artist_2)
print(result)
return result
print("Hello world!")
if __name__ == "__main__":
uvicorn.run(app, host="localhost", port=5000, log_level="info")