from flask import Flask, url_for, Markup, request from flask_login import current_user from werkzeug.routing import BaseConverter app = Flask(__name__) app.config.from_pyfile('fbin.cfg') # Set up some custom converters. These are needed for file URLs to be properly parsed. class HashConverter(BaseConverter): regex = r'\w+' class ExtensionConverter(BaseConverter): regex = r'\.\w+' app.url_map.converters['hash'] = HashConverter app.url_map.converters['ext'] = ExtensionConverter @app.context_processor def context_processors(): def nav_html(view, name=None): url = url_for(view) if not name: name = view.rsplit('.', 1)[-1].replace('_', ' ').capitalize() if view == '.logout': name += ' [{}]'.format(current_user.username) return Markup('