我在 VS code 上有以下文件,当我尝试在浏览器上运行它们时,它根本无法识别是否存在任何 reg.html 模板。有什么问题吗?蟒蛇文件from flask import Flask, render_template, flashapp = Flask(__name__)app.config["SECRET_KEY"] = "asdfghjkl"@app.route("/")def form(): return render_template("reg.html", title = "Form")if __name__ == "__main__": app.run(debug = True)html 文件 (reg.html)!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login/Signup - ((title)) </title><!-- Bootstrap CSS--><link rel = "stylesheet" href = "(( url for('static', filename = 'css/bootstrap.min.css)' ))"><link rel = "stylesheet" href = "(( url for('static', filename = 'css/site.css') ))"> </head><body> <div class = "container"> <div class = "row"> <div class = "col-md-5"> <h1 class = "text-center">Registration form</h1> </div> <div class = "col-md-2"></div> <div class = "col-md-2"></div> </div></div><!-- Javascript --><script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script><script src="https://cdn.js.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script><script src = "((url for ('static', filename = 'js/bootstrap.min.js')))">`</script>`</body></html>
1 回答
繁星淼淼
TA贡献1775条经验 获得超11个赞
为了解决这个问题,创建一个名为 的文件夹templates
,Flask 默认在该文件夹中查找模板,然后将 reg.html 放入该文件夹中:
启动程序,您将观察结果:
添加回答
举报
0/150
提交
取消