old_contents: import os.path
  
  from flask import Blueprint, Flask, send_from_directory, current_app, send_file
  
  
  # Look in the 'dxr' package for static files, templates, etc.:
  dxr_blueprint = Blueprint('dxr_blueprint', 'dxr')
  
  
  def make_app(instance_folder):
      """Return a DXR application which looks in the given folder for
      configuration.
  
      Also set up the static and template folder according to the configured
      template.
  
      """
      # TODO: Actually obey the template selection in the config file by passing
      # a different static_folder and template_folder to Flask().
      app = Flask('dxr', instance_path=instance_folder)
      app.register_blueprint(dxr_blueprint)
  
      # Load the special config file generated by dxr-build:
      app.config.from_pyfile(os.path.join(app.instance_path, 'config.py'))
      return app
  
  
  @dxr_blueprint.route('/')
  def index():
      return send_file(current_app.open_instance_resource('trees/index.html'))
  
  
  @dxr_blueprint.route('/search')
  def search():
      """Search by regex, caller, superclass, or whatever."""
      return 'searched!'
  
  
  @dxr_blueprint.route('/<path:tree_and_path>')
  def browse(tree_and_path):
      """Show a directory listing or a single file from one of the trees."""
      tree, _, path = tree_and_path.partition('/')
      return send_from_directory(
          os.path.join(current_app.instance_path, 'trees', tree),
          path)
  
new_contents: import os.path
  from os.path import isdir
  
  from flask import Blueprint, Flask, send_from_directory, current_app, send_file
  
  
  # Look in the 'dxr' package for static files, templates, etc.:
  dxr_blueprint = Blueprint('dxr_blueprint', 'dxr')
  
  
  def make_app(instance_folder):
      """Return a DXR application which looks in the given folder for
      configuration.
  
      Also set up the static and template folder according to the configured
      template.
  
      """
      # TODO: Actually obey the template selection in the config file by passing
      # a different static_folder and template_folder to Flask().
      app = Flask('dxr', instance_path=instance_folder)
      app.register_blueprint(dxr_blueprint)
  
      # Load the special config file generated by dxr-build:
      app.config.from_pyfile(os.path.join(app.instance_path, 'config.py'))
      return app
  
  
  @dxr_blueprint.route('/')
  def index():
      return send_file(current_app.open_instance_resource('trees/index.html'))
  
  
  @dxr_blueprint.route('/search')
  def search():
      """Search by regex, caller, superclass, or whatever."""
      return 'searched!'
  
  
  @dxr_blueprint.route('/<path:tree_and_path>')
  def browse(tree_and_path):
      """Show a directory listing or a single file from one of the trees."""
      tree, _, path = tree_and_path.partition('/')
      tree_folder = os.path.join(current_app.instance_path, 'trees', tree)
  
      if isdir(os.path.join(tree_folder, path)):
          # It's a bare directory. Add the index file to the end:
          path = os.path.join(path, current_app.config['DIRECTORY_INDEX'])
      else:
          # It's a file. Add the .html extension:
          path += '.html'
  
      return send_from_directory(tree_folder, path)
  
subject: Make directory listings and ".html"-less source code URLs work.