from fastapi import FastAPI, Request import httpx from fastapi.responses import HTMLResponse app = FastAPI() @app.get("/proxy", response_class=HTMLResponse) 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