|
from fastapi import FastAPI, Request |
|
from fastapi.responses import JSONResponse |
|
|
|
app = FastAPI() |
|
|
|
@app.all("/{path:path}") |
|
async def proxy(request: Request, path: str): |
|
async with httpx.AsyncClient() as client: |
|
|
|
method = request.method |
|
url = f"http://52.91.103.39:1234/{path}" |
|
|
|
|
|
headers = dict(request.headers) |
|
|
|
|
|
content = await request.body() |
|
|
|
|
|
response = await client.request( |
|
method=method, |
|
url=url, |
|
headers=headers, |
|
content=content |
|
) |
|
|
|
|
|
return JSONResponse(content=response.json(), status_code=response.status_code) |
|
|
|
|
|
|
|
|