Last active
November 6, 2018 23:05
-
-
Save antoinelebel/dabb60d3dfe63829136499a321394926 to your computer and use it in GitHub Desktop.
Décorateur
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
def login_required(f): | |
def decorated_function(*args, **kwargs): | |
if g.user is None: | |
return redirect(url_for('login', next=request.url)) | |
return f(*args, **kwargs) | |
return decorated_function | |
@app.route('/api/log') | |
@login_required | |
def get(): | |
response = { | |
"logs" : [ | |
"log1data", | |
"log2data" | |
] | |
} | |
return jsonify(response) | |
@app.route('/', defaults={'path': ''}) | |
@app.route('/<path:path>') | |
def catch_all(path): | |
return render_template("index.html") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment