title: Redirecting to the resource file in static directory with Flask
body: <p>I have a static directory that contains some resources (data files), and I can access the files directly: i.e., <code>http://hello.com/static/dir/abc.pdf</code>. However, I got error with the directory as the address: i.e., <code>http://hello.com/static/dir</code>. </p>
  
  <p>Using flask, I can solve this issue by showing the contents of the directory.</p>
  
  <pre><code>@app.route('/static/&lt;path:url&gt;') @protect 
  def show(url):
      content_dir = app.config['CONTENT_DIR']
      directory = "%s/%s/box/%s" % (content_dir, url, url2)
      result = []
  
      if os.path.isdir(directory):
          for file in os.listdir(directory):
              content['url'] = '/static/...
          result.append(content)
      return render_template("box.html",...)
  </code></pre>
  
  <p>The issue is that with this route processing, the direct file accessing doesn't work any more as <code>http://hello.com/static/dir/abc.pdf</code> always triggers the <code>show()</code> method. </p>
  
  <p>How can I redirect to the resource file (abc.pdf in the example), without being redirected to the <code>show()</code> method? </p>