pngwn HF Staff commited on
Commit
fb032b1
·
verified ·
1 Parent(s): e046c45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import httpx
2
  from fastapi import FastAPI, Request
3
- from fastapi.responses import StreamingResponse, JSONResponse
4
  from fastapi.middleware.cors import CORSMiddleware
5
  import uvicorn
6
  import subprocess
@@ -134,20 +134,20 @@ async def proxy_to_node(
134
  )
135
 
136
  req = client.build_request("GET", httpx.URL(url), headers=headers)
137
- r = await client.send(req, stream=True)
138
  print(f"Time to prepare request: {time.time() - start_time:.4f} seconds")
139
 
140
  print(f"\nHeaders: {r.headers}\n")
141
 
142
- new_headers = {
143
- key: value
144
- for key, value in r.headers.items()
145
- if key.lower() != "content-length"
146
- }
147
 
148
  new_headers["Transfer-Encoding"] = "chunked"
149
 
150
- return StreamingResponse(r.aiter_raw(), headers=new_headers)
151
 
152
 
153
  @app.api_route(
 
1
  import httpx
2
  from fastapi import FastAPI, Request
3
+ from fastapi.responses import Response, StreamingResponse, JSONResponse
4
  from fastapi.middleware.cors import CORSMiddleware
5
  import uvicorn
6
  import subprocess
 
134
  )
135
 
136
  req = client.build_request("GET", httpx.URL(url), headers=headers)
137
+ r = await client.send(req)
138
  print(f"Time to prepare request: {time.time() - start_time:.4f} seconds")
139
 
140
  print(f"\nHeaders: {r.headers}\n")
141
 
142
+ # new_headers = {
143
+ # key: value
144
+ # for key, value in r.headers.items()
145
+ # if key.lower() != "content-length"
146
+ # }
147
 
148
  new_headers["Transfer-Encoding"] = "chunked"
149
 
150
+ return Response(r.aiter_raw(), headers=r.headers)
151
 
152
 
153
  @app.api_route(