from flask import Blueprint, render_template from flask_login import current_user main_bp = Blueprint('main', __name__) @main_bp.route('/') def index(): """首页""" return render_template('index.html') @main_bp.route('/dashboard') def dashboard(): """用户主页(需要登录)""" if current_user.is_authenticated: return render_template('dashboard.html') else: return render_template('index.html')