Created
September 12, 2013 11:11
-
-
Save danielrichman/6535866 to your computer and use it in GitHub Desktop.
python-raven (+flask) replacement for .htaccess+mod_ucam_webauth
This file contains hidden or 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
| import os | |
| from os.path import dirname, realpath | |
| from os.path import join as path_join | |
| from flask import Flask | |
| from flask.helpers import send_from_directory | |
| from raven.flask_glue import AuthDecorator | |
| app = Flask(__name__) | |
| assert not app.has_static_folder | |
| app.secret_key = os.urandom(16) | |
| require_principal = ["djr61"] | |
| auth_decorator = AuthDecorator(require_principal=users) | |
| app.before_request(auth_decorator.before_request) | |
| content_folder = realpath(path_join(dirname(__file__), 'content')) | |
| @app.route("/<path:filename>") | |
| def serve(filename): | |
| return send_from_directory(content_folder, 'content', filename) | |
| if __name__ == '__main__': | |
| app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment