-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (46 loc) · 1.04 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from fastapi import FastAPI
app = FastAPI()
import pycine.tmdb as tmdb
from fastapi.middleware.cors import CORSMiddleware
"""
# Iniciar fastapi (main.py) no servidor uvicorn:
source env/bin/activate
uvicorn main:app --reload
"""
origins = [
"http://localhost",
"http://localhost:*",
"http://localhost:5173",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
def hello():
return {"status": "pycine is running"}
@app.get("/movie/{id}")
def get_movie(id: int):
return tmdb.get_movie(id)
@app.get("/search/movies")
def search_movies():
"""
Filmes mais populares
http :8000/search/movies
"""
params = {
"sort_by": "vote_count.desc"
}
# results = tmdb.search_movies() # shawshaw
results = tmdb.search_movies(params) # inception
return results
@app.get("/movies/top")
def search_movies():
"""
# Retorna os 20 filmes mais populares
"""
results = tmdb.search_movies()
return results