服务端代码:

from flask import Flask, request, render_template

app = Flask(__name__)


@app.route('/')
def index():
    variable={"name": "张三"}
    return render_template("index.html", variable=variable)


@app.errorhandler(404)
def miss(e):
    return render_template('404.html'), 404


@app.errorhandler(500)
def error(e):
    return render_template('500.html'), 500


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5002, debug=True)

html页面使用

        <p>{{variable.name}}</p>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2021-12-30
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案