装饰器,验证当前session中是否存在定义的user_id,没有就重定向到登录页 from flask import session, redirect, url_forfrom functools import wraps import config def login_required(func): @wraps(func) def inner(*args, **kwargs): return func(*args, **kwargs) if config.CMS_USER_ID in s…