flask路由分配 路由外定义方法

def fun1():
    return render_template('./login.html')
def fun2():
    code

@blue.route('/',methods=['GET',])
def login():
    fun1()

@blue.route('/index/',methods=['GET',])
def index():
    fun2()
    return render_template('./index.html')

在路由里可以调用上面的fun()跳转到login页面吗?我怎么老是报错 不知道哪里出了问题 如果不可以怎么解决这种问题呢?? 小白求助 感谢

你的login 没有返回值啊 你的login可以改成这样

def fun1():
    return render_template('./login.html')
def fun2():
    code

@blue.route('/',methods=['GET',])
def login():
    return fun1()

@blue.route('/index/',methods=['GET',])
def index():
    fun2()
    return render_template('./index.html')

起码显示一下错误信息,理论上调用fun1函数是没问题的