from flask import Flask, url_for, Markup, request from flask_login import current_user from werkzeug.routing import BaseConverter from werkzeug.middleware.proxy_fix import ProxyFix app = Flask(__name__) app.config.from_pyfile('fbin.cfg') app.wsgi_app = ProxyFix(app.wsgi_app) # 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.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('