Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

525
Views
Return File/Stream response from googlevideo in Fast API

I am using Fast API to return a video response from googlevideo.com. This is the code I am using:

@app.get(params.api_video_route)
async def get_api_video(url=None):

  def iter():
     req = urllib.request.Request(url)

     with urllib.request.urlopen(req) as resp:
         yield from io.BytesIO(resp.read())


  return StreamingResponse(iter(), media_type="video/mp4")

but this is not working

I want this Nodejs to be converted into python FAST API:

app.get("/download-video", function(req, res) { 
 http.get(decodeURIComponent(req.query.url), function(response) { 
   res.setHeader("Content-Length", response.headers["content-length"]); 
   if (response.statusCode >= 400)         
     res.status(500).send("Error");                     
     response.on("data", function(chunk) { res.write(chunk); }); 
     response.on("end", function() { res.end(); }); }); });
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use the below instead, as described in the documentation here.

#yield from io.BytesIO(resp.read())
yield from resp
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!