- Added Jinja2 templating to index.html for dynamic opengraph, tags, titles, and descriptions for bots via flask's render_template - Added index_tags.py to config folder for easily edited information for the update above - Added helmet to react to dynamically change the title of the tab for dynamic tabs even after a static index.html has been served by flask's render template
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
from flask import Blueprint, send_from_directory, request, render_template
|
|
import os
|
|
from configs import index_tags
|
|
|
|
react_bp = Blueprint('react_bp', __name__, static_folder=f'{os.getcwd()}/cdrm-frontend/dist', static_url_path='/',
|
|
template_folder=f'{os.getcwd()}/cdrm-frontend/dist')
|
|
|
|
@react_bp.route('/', methods=['GET'])
|
|
@react_bp.route('/<path:path>', methods=["GET"])
|
|
@react_bp.route('/<path>', methods=["GET"])
|
|
def index(path=''):
|
|
if request.method == 'GET':
|
|
if path != "" and os.path.exists(react_bp.static_folder + '/' + path):
|
|
return send_from_directory(react_bp.static_folder, path)
|
|
elif path.lower() == '':
|
|
data = index_tags.tags['index']
|
|
return render_template('index.html', data=data)
|
|
elif path.lower() == 'cache':
|
|
data = index_tags.tags['cache']
|
|
return render_template('index.html', data=data)
|
|
elif path.lower() == 'api':
|
|
data = index_tags.tags['api']
|
|
return render_template('index.html', data=data)
|
|
elif path.lower() == 'testplayer':
|
|
data = index_tags.tags['test_player']
|
|
return render_template('index.html', data=data)
|
|
else:
|
|
return send_from_directory(react_bp.static_folder, 'index.html')
|
|
else:
|
|
return
|