title: NameError: global name 'send_from_directory' is not defined
body: <p>I am working with Flask and trying to serve a file for the user to download.</p>
  
  <p>My code looks something like this:</p>
  
  <pre><code>@app.route('/downloads/&lt;string:yt_id&gt;')
  def download_file(yt_id):
  
      def hooks(data):
          if data['status'] == 'finished':
              filename = data['filename']
  
      ydl_opts = {
          'format': 'bestaudio/best',
          'postprocessors': [{
              'key': 'FFmpegExtractAudio',
              'preferredcodec': 'mp3',
              'preferredquality': '192',
          }],
          'progress_hooks': [hooks],
      }
      with youtube_dl.YoutubeDL(ydl_opts) as ydl:
          ydl.download(['http://www.youtube.com/watch?v='+yt_id])
  
  
      return send_from_directory(".",
                                 filename,
                                 as_attachment=True)
  </code></pre>
  
  <p>I guess the only relevant part of the above code is this:</p>
  
  <pre><code>    return send_from_directory(".",
                                 filename,
                                 as_attachment=True)
  </code></pre>
  
  <p>And this is the error message that I'm getting:</p>
  
  <pre><code>NameError: global name 'send_from_directory' is not defined
  </code></pre>
  
  <p>I have looked at several examples of how people are using <code>send_from_directory</code> and I don't see much difference with what I am doing. So any help would be greatly appreciated.</p>