Skip to content

Instantly share code, notes, and snippets.

@antoinelebel
Last active November 6, 2018 23:05
Show Gist options
  • Save antoinelebel/dabb60d3dfe63829136499a321394926 to your computer and use it in GitHub Desktop.
Save antoinelebel/dabb60d3dfe63829136499a321394926 to your computer and use it in GitHub Desktop.
Décorateur
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