在以下代码中:

@app.route('/func')
def func():
    if 'username' not in session:
        return redirect(url_for('login'))
    return render_template('func')

render_template 函数需要传入模板文件的名称,但是在这里只传入了字符串 'func',应该改为:

@app.route('/func')
def func():
    if 'username' not in session:
        return redirect(url_for('login'))
    return render_template('func.html')

同样地,在以下代码中:

return redirect(url_for('func.html'))

url_for 函数只需要传入视图函数的名称,不需要加上 .html 后缀,应该改为:

return redirect(url_for('func'))
``
from flask import Flask render_template request redirect url_for flash sessionfrom scapyall import import osimport timeimport sysimport platformfrom scapylayersl2 import Etherfrom scapylayersl2 import

原文地址: http://www.cveoy.top/t/topic/fsNa 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录