Update app.py
Browse files
app.py
CHANGED
@@ -62,7 +62,27 @@ async def search(
|
|
62 |
return JSONResponse(content=jsonable_encoder(results))
|
63 |
except Exception as e:
|
64 |
raise HTTPException(status_code=500, detail=f"Error during search: {e}")
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
@app.get("/api/images")
|
67 |
async def images(
|
68 |
q: str,
|
|
|
62 |
return JSONResponse(content=jsonable_encoder(results))
|
63 |
except Exception as e:
|
64 |
raise HTTPException(status_code=500, detail=f"Error during search: {e}")
|
65 |
+
|
66 |
+
@app.get("/api/search_google")
|
67 |
+
async def search_google(
|
68 |
+
q: str,
|
69 |
+
max_results: int = 10,
|
70 |
+
safesearch: str = "moderate",
|
71 |
+
region: str = "wt-wt",
|
72 |
+
proxy: Optional[str] = None
|
73 |
+
):
|
74 |
+
"""Perform a text search."""
|
75 |
+
try:
|
76 |
+
with GoogleS(proxy=proxy) as webs:
|
77 |
+
results = webs.search(
|
78 |
+
query=q,
|
79 |
+
region=region,
|
80 |
+
safesearch=safesearch,
|
81 |
+
max_results=max_results,
|
82 |
+
)
|
83 |
+
return JSONResponse(content=jsonable_encoder(results))
|
84 |
+
except Exception as e:
|
85 |
+
raise HTTPException(status_code=500, detail=f"Error during search: {e}")
|
86 |
@app.get("/api/images")
|
87 |
async def images(
|
88 |
q: str,
|