1、修改之前创建的flask代码
2、启动该项目
3、浏览器中查看
这样一个最简单的web项目就创建完成了
下面我们需要自己的项目跳转到我们自定义的页面。
4、在templates文件夹中创建HTML页面index.html
5、修改app.py,导入render_template,以及修改index.html文件
app.py
from flask import Flask,render_template
app = Flask(__name__)
@app.route('/')
def hello_world():
render_template('index.html',data='welcome to china!')
if __name__ == '__main__':
app.run(debug=True)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>