title: Play a downloaded video with flask
body: <p>I have a simple flask server. I downloaded, using pafy, a video from a youtube link provided by the user.</p>
  
  <pre><code>@app.route('/')
  def download():
      return render_template('basic.html')
  </code></pre>
  
  <p>The basic.html template has a form that submits an action to download:</p>
  
  <pre><code>&lt;form action="download_vid" method="post"&gt;
  Link: &lt;input type="text" name="download_path"&gt;&lt;br&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I have another end point, /download_vid that looks like this.</p>
  
  <pre><code>@app.route('/download_vid', methods=['POST'])
  def download_vid():
      url = request.form['download_path']
      v = pafy.new(url)
      s = v.allstreams[len(v.allstreams)-1]
      filename = s.download("static/test.mp4")
      return redirect(url_for('done'))
  </code></pre>
  
  <p>The desired link is indeed downloaded as a .mp4 file in my static folder. I can watch it and I can also use it as a source for a  tag in an HTML file, if I open it locally.</p>
  
  <pre><code>@app.route('/done')
  def done():
      return app.send_static_file('test.mp4')
  </code></pre>
  
  <p>From what I understand, 'send_static_file' serves files from the static directory. However, I get a 404 error when I run the server, even though the video is clearly there.</p>
  
  <p>I have also tried a different version for done():</p>
  
  <pre><code>@app.route('/done')
  def done():
      return return render_template('vid.html')
  </code></pre>
  
  <p>Here, vid.html resides in templates and has a hard coded path to static/test.mp4. It is loaded after the download is complete. I do not have a 404 error in this case, but the  tag don't do anything, it's just gray. If I open vid.html locally (double click on it), it works, it shows the video.</p>
  
  <p>Can you please help me understand what is going on?</p>
  
  <p>What I want to achieve is this:</p>
  
  <ol>
  <li>Take an input from the user [ Done ]</li>
  <li>Use that input to download a video [ Done ]</li>
  <li>Serve that video back to the user [ ??? ]</li>
  </ol>