title: Flask: Handle catch all url different if path is directory or file
body: <p>How can I make a catch all route, that only handles directories and one that handles files?</p>
  
  <p>Below is a simple example</p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  @app.route('/foo')
  def foo_file():
      return 'Queried: foo file'
  
  @app.route('/foo/')
  def foo_dir():
      return 'Queried:  foo dir'
  
  @app.route('/&lt;path:path&gt;')
  def file(path):
      return 'Queried file: {0}'.format(path)
  
  @app.route('/')
  @app.route('/&lt;path:path&gt;/')
  def folder(path):
      return 'Queried folder: {0}'.format(path)
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p>When I access <code>http:\\127.0.0.1:5000\foo</code> It calls <code>foo_file()</code> and for <code>http:\\127.0.0.1:5000\foo\</code> it calls <code>foo_dir()</code>. But querying <code>http:\\127.0.0.1:5000\bar</code> and <code>http:\\127.0.0.1:5000\bar\</code> both call
  <code>file()</code>. How can I change that?</p>
  
  <p>I know I can check the trailing slash and reroute manually, I was just wondering if there's another way.</p>