-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (38 loc) · 1.21 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
53
54
55
from enum import Enum
import httpx
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
origins = [
"https://jsearch-latest.onrender.com",
"https://jsearch.lostmypillow.duckdns.org",
"https://lostmypillow.github.io",
"http://localhost:3000"
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
expose_headers=["*"]
)
@app.get("/get-movies/")
async def get_movies(query: str):
print("yest")
url = f"https://www.omdbapi.com/?apikey=e9cb394&s={query}"
r = httpx.get(url)
print(r)
print(r.headers['content-type'])
return {"results": r.json()}
@app.get("/get-google/")
async def get_google(query: str, limit: int, related: bool):
url = f'https://google-search74.p.rapidapi.com/?query={query}&limit={limit}&related_keywords={related}'
headers = {
"X-RapidAPI-Key": "4cc2304fb3msh28544a85c39f266p17c92bjsnd635c2ee140a",
"X-RapidAPI-Host": "google-search74.p.rapidapi.com",
}
r = httpx.get(url, headers=headers)
print(r.json())
return {"results": r.json()}