andrewammann commited on
Commit
c5e7785
·
verified ·
1 Parent(s): c730e00

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Request
2
+ import httpx
3
+ from fastapi.responses import HTMLResponse
4
+
5
+ app = FastAPI()
6
+
7
+ @app.get("/proxy", response_class=HTMLResponse)
8
+ async def proxy(request: Request):
9
+ query = request.query_params.get("q")
10
+ if not query:
11
+ return "Please provide a query parameter `q`."
12
+ headers = {"User-Agent": "Mozilla/5.0"}
13
+ async with httpx.AsyncClient() as client:
14
+ response = await client.get(f"https://www.google.com/search?q={query}", headers=headers)
15
+ return response.text