| from flask import Flask, request, url_for, Markup |
| |
| from hswaw.lib.flask_spaceauth.spaceauth import SpaceAuth, login_required, \ |
| cap_required, current_user |
| |
| app = Flask('spaceauth-example') |
| app.config['SECRET_KEY'] = 'testing' |
| app.config['SPACEAUTH_CONSUMER_KEY'] = 'testing' |
| app.config['SPACEAUTH_CONSUMER_SECRET'] = 'asdTasdfhwqweryrewegfdsfJIxkGc' |
| auth = SpaceAuth(app) |
| |
| @app.route('/') |
| def index(): |
| return Markup('Hey! <a href="%s">Login with spaceauth</a> / %r') % ( |
| url_for('spaceauth.login'), current_user) |
| |
| @app.route('/profile') |
| @login_required |
| def profile(): |
| return Markup('Hey {}!').format(spaceauth.current_user) |
| |
| @app.route('/staff') |
| @cap_required('staff') |
| def staff_only(): |
| return 'This is staff-only zone!' |
| |
| |
| if __name__ == "__main__": |
| app.run() |