Spaces:
BG5
/
Running

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

Update fun.py

Browse files
Files changed (1) hide show
  1. fun.py +7 -4
fun.py CHANGED
@@ -7,9 +7,10 @@ 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
- if path == "":
11
- # 拒绝根目录
12
- return Response(content="Not Found", status_code=status.HTTP_404_NOT_FOUND)
 
13
  url = f"{TARGET_BASE}/{path}"
14
  headers = dict(request.headers)
15
  body = await request.body()
@@ -27,6 +28,8 @@ async def proxy(request: Request, path: str):
27
  headers=dict(resp.headers)
28
  )
29
 
 
30
  if __name__ == "__main__":
31
  # 运行FastAPI应用
32
- uvicorn.run("fun:app", host="0.0.0.0", port=8000, reload=True)
 
 
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)
14
  url = f"{TARGET_BASE}/{path}"
15
  headers = dict(request.headers)
16
  body = await request.body()
 
28
  headers=dict(resp.headers)
29
  )
30
 
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)