kenton-li commited on
Commit
ebad03c
1 Parent(s): 3e43332

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -9
main.py CHANGED
@@ -6,7 +6,7 @@ app = FastAPI()
6
 
7
  @app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"])
8
  async def proxy(request: Request, path: str):
9
- target_url = f"http://www.medicalgpt.club/{path}"
10
 
11
  async with httpx.AsyncClient() as client:
12
  method = request.method
@@ -22,18 +22,12 @@ async def proxy(request: Request, path: str):
22
  content=content
23
  )
24
 
25
- # Process the Location header if present in the response
26
- response_headers = dict(response.headers)
27
- if "Location" in response_headers:
28
- # Replace the target URL with the proxy URL
29
- response_headers["Location"] = response_headers["Location"].replace("http://www.medicalgpt.club", request.base_url)
30
-
31
  return Response(
32
  content=response.content,
33
  status_code=response.status_code,
34
- headers=response_headers
35
  )
36
 
37
  if __name__ == "__main__":
38
  import os
39
- os.system("uvicorn main:app --host 0.0.0.0 --port 7860")
 
6
 
7
  @app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"])
8
  async def proxy(request: Request, path: str):
9
+ target_url = f"http://93.188.161.18:5000/{path}"
10
 
11
  async with httpx.AsyncClient() as client:
12
  method = request.method
 
22
  content=content
23
  )
24
 
 
 
 
 
 
 
25
  return Response(
26
  content=response.content,
27
  status_code=response.status_code,
28
+ headers=dict(response.headers)
29
  )
30
 
31
  if __name__ == "__main__":
32
  import os
33
+ os.system("uvicorn main:app --host 0.0.0.0 --port 7860")