-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
54 lines (47 loc) · 1.05 KB
/
app.py
File metadata and controls
54 lines (47 loc) · 1.05 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from fastapi import FastAPI, Path
from fastapi.middleware.cors import CORSMiddleware
from contentBasedFiltering import *
app = FastAPI()
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
def get_dashboard_data():
try:
res = {
"success": True,
"top25imdb": top25imdb,
"topActions": action,
"topAnimated": animated
}
return res
except:
return { "success": False }
@app.get("/movie/{id}")
def get_movie_details(id: int = Path(description="The ID of the movie")):
try:
Movies = RecommendedList(id)
GetMovieByIndex = getMovieDetails(id)
return {
"success": True,
"details": GetMovieByIndex,
"movies": Movies
}
except:
return { "success": False }
@app.get("/search")
def get_movies_by_name(query: str):
try:
searchRes = searchTitle(query)
res = {
"success": True,
"results": searchRes,
}
return res
except:
return { "success": False }