Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法使用blueprint Flask路由_Python_Flask - Fatal编程技术网

Python 无法使用blueprint Flask路由

Python 无法使用blueprint Flask路由,python,flask,Python,Flask,我按照中的说明,尝试在创建应用程序对象的脚本之外的其他脚本中执行路由。但我得到的错误是 “服务器遇到内部错误,无法完成您的请求。服务器过载或应用程序出错。” 它只是忽略了我在脚本中所做的路由 restservice = Blueprint('restservice', __name__,template_folder='templates') @restservice.route('/') def approot(): render_template('timeline.html')

我按照中的说明,尝试在创建应用程序对象的脚本之外的其他脚本中执行路由。但我得到的错误是

“服务器遇到内部错误,无法完成您的请求。服务器过载或应用程序出错。”

它只是忽略了我在脚本中所做的路由

restservice = Blueprint('restservice', __name__,template_folder='templates')

@restservice.route('/')
def approot():
   render_template('timeline.html')

假设您的蓝图位于名为restservice.py的文件中,您需要在创建应用程序对象的文件中添加这些行

from restservice import restservice as restModule
app.register_blueprint(restModule)

假设您的蓝图位于名为restservice.py的文件中,您需要在创建应用程序对象的文件中添加这些行

from restservice import restservice as restModule
app.register_blueprint(restModule)

请在启用调试的情况下运行你的应用程序(
app.run(debug=True)
),并在此处发布回溯。是的,使用你的app.run(debug=True)调试技术,我能够自己解决错误。通过这次调试,我发现蓝图没有被忽略,但问题出在模块内部。通过这种调试技术,它被打印在日志中。非常感谢。请在启用调试的情况下运行你的应用程序(
app.run(debug=True)
),并在此处发布回溯。是的,使用你的app.run(debug=True)调试技术,我能够自己解决错误。通过这次调试,我发现蓝图没有被忽略,但问题出在模块内部。通过这种调试技术,它被打印在日志中。非常感谢你。