Python代码:
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def hello():
return render_template('testing.html')
if __name__ == "__main__":
app.run()
HTML 文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>My name is pk</h1>
</body>
</html>
另外如何在 pycharm 社区版本中启用 jinja2。我直接在同一个项目中创建html文件和.py文件
烧瓶文件结构
|-app
|--templates // where your html files must be in
|--static // where your js and css files must be in
|--.py files
|--other packages
如果您已经安装了 Flask,那么 jinja2 也在您的 python 环境中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)