Add simple example
parent
0f997ab8fa
commit
2ed8d3e9f7
|
@ -0,0 +1,27 @@
|
|||
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()
|
Loading…
Reference in New Issue