From 841e9d37d103f4fb36b1f456fe8d425a256ead54 Mon Sep 17 00:00:00 2001 From: Bui Date: Tue, 17 Mar 2020 04:03:10 +0000 Subject: [PATCH] add csrftoken api route --- app.py | 6 +++++- templates/admin_songs.html | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 45d9a7b..0667bba 100644 --- a/app.py +++ b/app.py @@ -112,7 +112,6 @@ def get_config(): config_out['assets_baseurl'] = ''.join([request.host_url, 'assets']) + '/' config_out['_version'] = get_version() - config_out['_csrf_token'] = generate_csrf() return config_out @@ -138,6 +137,11 @@ def route_index(): return render_template('index.html', version=version, config=get_config()) +@app.route('/api/csrftoken') +def route_csrftoken(): + return jsonify({'status': 'ok', 'token': generate_csrf()}) + + @app.route('/admin') @admin_required(level=50) def route_admin(): diff --git a/templates/admin_songs.html b/templates/admin_songs.html index 1c384a4..2ef70ee 100644 --- a/templates/admin_songs.html +++ b/templates/admin_songs.html @@ -10,7 +10,11 @@ {% for song in songs %}
-

{{ song.title }}

+ {% if song.title_lang.en %} +

{{ song.title_lang.en }} ({{ song.title }})

+ {% else %} +

{{ song.title }}

+ {% endif %}
{% endfor %}