title: Send file returns blank video
body: <p>I am trying to make a YouTube front end website thing. When I enter a YouTube video name, it returns a blank video. I attached an image of it. What is wrong with the code? Does it have something to do with formats when youtube-dl downloads them?</p>
  <p><a href="https://i.stack.imgur.com/1qA0Y.png" rel="nofollow noreferrer">Picture is here</a></p>
  <p>Main.py:</p>
  <pre><code>import youtube_dl
  import random
  import os
  
  
  for x in os.listdir(&quot;./&quot;):
    if x.endswith((&quot;.mp4&quot;, &quot;.webm&quot;, &quot;.mkv&quot;)):
      os.remove(x)
  
  
  
  app = flask.Flask(__name__)
  
  
  
  @app.route(&quot;/&quot;)
  def main():
    return flask.render_template(&quot;main.html&quot;)
  
  @app.route(&quot;/download/&quot;, methods=[&quot;POST&quot;, &quot;GET&quot;])
  def download():
    
    if flask.request.method == &quot;POST&quot;:
      number = random.randint(1, 400)
      ytdl = youtube_dl.YoutubeDL({&quot;outtmpl&quot; : f&quot;{number}&quot;})
      title = flask.request.form.get(&quot;title&quot;)
      ytdl.download([f&quot;ytsearch:{title}&quot;])
      return flask.redirect(f&quot;/video/{number}&quot;)
  
  
  
  @app.route(&quot;/video/&lt;number&gt;&quot;)
  def video(number):
    return flask.render_template(&quot;video.html&quot;, number=number)
  
  
  
  @app.route(&quot;/source/&lt;number&gt;&quot;)
  def source(number):
    for x in os.listdir(&quot;./&quot;):
      if x.startswith(f&quot;{number}&quot;):
        return flask.send_file(x)
  
    
  app.run(&quot;0.0.0.0&quot;)
  </code></pre>
  <p>Main.html:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;h1&gt;Please enter a title&lt;/h1&gt;
  &lt;form method=&quot;POST&quot; action=&quot;/download/{{title}}&quot;&gt;
    &lt;input type=&quot;text&quot; name=&quot;title&quot;&gt;
    &lt;button type=&quot;submit&quot;&gt;Ok&lt;/button&gt;
  &lt;/form```
  
  Video.html:
  
  ```html
  &lt;video width=&quot;320&quot; height=&quot;240&quot; controls playsinline&gt;
      &lt;source src=&quot;/source/{{number}}&quot; type=&quot;video/mp4&quot; /&gt;
    &lt;/video&gt;```
  </code></pre>