28 lines
755 B
Python
28 lines
755 B
Python
from flask import Flask, request, url_for, Markup
|
|
from spaceauth import SpaceAuth, login_required, cap_required
|
|
|
|
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'), spaceauth.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()
|