Created
March 8, 2013 19:03
-
-
Save erikrose/5118928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment