BG5 commited on
Commit
822dfb3
·
verified ·
1 Parent(s): a9fe695

Update fun.py

Browse files
Files changed (1) hide show
  1. fun.py +4 -3
fun.py CHANGED
@@ -4,10 +4,12 @@ import uvicorn
4
 
5
  app = FastAPI()
6
  TARGET_BASE = "http://127.0.0.1:8001" # 替换为你的目标服务器
7
-
 
8
  @app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"])
9
  async def proxy(request: Request, path: str):
10
- print(httpx.get(TARGET_BASE))
 
11
  # if path == "":
12
  # # 拒绝根目录
13
  # return Response(content="Not Found", status_code=status.HTTP_404_NOT_FOUND)
@@ -31,5 +33,4 @@ async def proxy(request: Request, path: str):
31
 
32
  if __name__ == "__main__":
33
  # 运行FastAPI应用
34
- print(httpx.get(TARGET_BASE))
35
  uvicorn.run("fun:app", host="0.0.0.0", port=8000)
 
4
 
5
  app = FastAPI()
6
  TARGET_BASE = "http://127.0.0.1:8001" # 替换为你的目标服务器
7
+ resp = httpx.get(TARGET_BASE)
8
+ print(f'RESP:{ resp.json}')
9
  @app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"])
10
  async def proxy(request: Request, path: str):
11
+ resp = httpx.get(TARGET_BASE)
12
+ print(f'RESP:{ resp.json}')
13
  # if path == "":
14
  # # 拒绝根目录
15
  # return Response(content="Not Found", status_code=status.HTTP_404_NOT_FOUND)
 
33
 
34
  if __name__ == "__main__":
35
  # 运行FastAPI应用
 
36
  uvicorn.run("fun:app", host="0.0.0.0", port=8000)