File size: 955 Bytes
50cf058 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import httpx
#from fastapi import FastAPI, Request
import requests
import json
import os
# current_user: User = Depends(get_current_active_user)):
# oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token")
# current_user: User = Depends(get_current_active_user)):
# oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token")
from fastapi import APIRouter, HTTPException
from gradio_client import Client
#router = APIRouter()
router = APIRouter(prefix="/gradio", tags=["gradio"])
@router.get("/route/proxy")
#LARAVEL_URL="http://localhost:8000"
LARAVEL_URL="http://localhost:8000"
@app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE"])
async def proxy(request: Request, path: str):
client = httpx.AsyncClient()
req_data = await request.body()
proxied = await client.request(
request.method,
f"{LARAVEL_URL}/{path}",
headers=request.headers.raw,
content=req_data
)
return proxied.text
|