2025-04-25 19:17:40 -04:00
|
|
|
from flask import Blueprint, send_from_directory, request, render_template
|
2025-04-24 17:06:14 -04:00
|
|
|
import os
|
2025-04-25 19:17:40 -04:00
|
|
|
from configs import index_tags
|
2025-04-24 17:06:14 -04:00
|
|
|
|
2025-04-25 19:17:40 -04:00
|
|
|
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')
|
2025-04-24 17:06:14 -04:00
|
|
|
|
|
|
|
@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)
|
2025-04-25 19:17:40 -04:00
|
|
|
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)
|
2025-04-24 17:06:14 -04:00
|
|
|
else:
|
|
|
|
return send_from_directory(react_bp.static_folder, 'index.html')
|
|
|
|
else:
|
|
|
|
return
|