Spaces:
No application file
No application file
| from fastapi import FastAPI, Request | |
| import httpx | |
| from fastapi.responses import HTMLResponse | |
| app = FastAPI() | |
| async def proxy(request: Request): | |
| query = request.query_params.get("q") | |
| if not query: | |
| return "Please provide a query parameter `q`." | |
| headers = {"User-Agent": "Mozilla/5.0"} | |
| async with httpx.AsyncClient() as client: | |
| response = await client.get(f"https://www.google.com/search?q={query}", headers=headers) | |
| return response.text | |