v1.8.0: 模块化重构 + 后台登录认证
This commit is contained in:
51
modules/routes/pages.py
Normal file
51
modules/routes/pages.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""
|
||||
页面路由
|
||||
"""
|
||||
from flask import Blueprint, render_template, redirect, url_for, session
|
||||
from config import CATEGORIES_FILE
|
||||
from utils import load_data
|
||||
from auth import require_auth
|
||||
|
||||
pages_bp = Blueprint('pages', __name__)
|
||||
|
||||
|
||||
@pages_bp.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@pages_bp.route('/models')
|
||||
def models_page():
|
||||
return render_template('models.html')
|
||||
|
||||
@pages_bp.route('/gpus')
|
||||
def gpus_page():
|
||||
return render_template('gpus.html')
|
||||
|
||||
@pages_bp.route('/cpus')
|
||||
def cpus_page():
|
||||
return render_template('cpus.html')
|
||||
|
||||
@pages_bp.route('/tools')
|
||||
def tools_page():
|
||||
return render_template('tools.html')
|
||||
|
||||
@pages_bp.route('/compare')
|
||||
def compare_page():
|
||||
return render_template('compare.html')
|
||||
|
||||
@pages_bp.route('/knowledge')
|
||||
def knowledge_page():
|
||||
return render_template('knowledge.html')
|
||||
|
||||
@pages_bp.route('/admin')
|
||||
@require_auth
|
||||
def admin_page():
|
||||
return render_template('admin.html')
|
||||
|
||||
@pages_bp.route('/category/<category_id>')
|
||||
def category_page(category_id):
|
||||
categories = load_data(CATEGORIES_FILE)
|
||||
category = next((c for c in categories if c['id'] == category_id), None)
|
||||
if not category:
|
||||
return "分类不存在", 404
|
||||
return render_template('category.html', category=category)
|
||||
Reference in New Issue
Block a user