File size: 1,739 Bytes
7845543
c575e18
 
970ba77
c575e18
4d5fb08
 
ff57cda
 
 
 
 
 
 
 
 
970ba77
2526e18
5bb8c78
 
970ba77
 
b916cdf
5bb8c78
b916cdf
5bb8c78
 
 
 
970ba77
 
5bb8c78
c575e18
5bb8c78
 
c575e18
970ba77
 
 
 
 
 
 
c575e18
970ba77
 
383fff6
 
6e4ee5d
b916cdf
c575e18
ce9a081
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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")