from fastapi import FastAPI, Request,Response from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse import httpx app = FastAPI() @app.get("/tg") async def tg() -> Response: with open("static/tg.html", "rb") as f: return Response(content=f.read(), media_type="text/html") @app.get("/test") async def tg() -> Response: return "test" @app.get("/getVPImage/{path:path}") async def get_vp_image(path: str): target_url = f"https://u7leyomozktm-5527.shanghai-01.dayunet.com/getVPImage/{path}" async with httpx.AsyncClient() as client: response = await client.get(target_url) return Response(content=response.content, media_type="image/jpeg", status_code=response.status_code) @app.post("/uploadVPMask/{path:path}") async def upload_vp_mask(path: str, request: Request): target_url = f"https://u7leyomozktm-5527.shanghai-01.dayunet.com/uploadVPMask/{path}" json_data = await request.json() async with httpx.AsyncClient() as client: response = await client.post(target_url, json=json_data) return response.text, response.status_code, response.headers.items() @app.post("/log-error") async def log_error(request: Request): target_url = "https://u7leyomozktm-5527.shanghai-01.dayunet.com/log-error" json_data = await request.json() async with httpx.AsyncClient() as client: response = await client.post(target_url, json=json_data) return response.text, response.status_code, response.headers.items() app.mount("/", StaticFiles(directory="static", html=True), name="static") @app.get("/") def index() -> FileResponse: return FileResponse(path="/app/static/index.html", media_type="text/html")