我想实现一个机器学习模型,但我实现了flask,我发现这个错误模板没有找到,即使我有模板文件夹。 我已经尝试了所有可能的解决方案给堆栈溢出,但没有工作,请帮助我。 基本代码是运行索引页,即使这样也不起作用
from flask import Flask,render_template
app = Flask(__name__, template_folder="C:/Users/sweet/Music/Rumor_Detection_Project_Copy/Front_End/templates")
app.debug=False
@app.route('/')
def index():
with app.app_context(), app.test_request_context():
template = render_template('C:/Users/sweet/Music/Rumor_Detection_Project_Copy/Front_End/templates/index.html')
if __name__ == "__main__":
app.run()
我试过的是:
请帮忙,因为这是最基本的,我还需要做很多其他的事情
该模板应存储在与flask脚本相同的目录中。然后可以通过将html文件的名称传递给render_template()函数来使用该模板
另外,decorator(
@app.route('/')
)和def函数之间不应该有空行您的代码应该如下所示:
相关问题 更多 >
编程相关推荐