1.Flask的安装

pip3 install flask

2.编写代码

from flask import Flask,Blueprint,send_file

app=Flask(__name__) #创建1个Flask实例


@app.route('/hi')      #路由系统生成 视图对应url,1. decorator=app.route() 2. decorator(first_flask)
def hello():    #视图函数
    return 'Hello World'  #response



@app.route('/')
def first_flask():    #视图函数
    print("in")
    return send_file('index.html')  #response


if __name__ == '__main__':
    app.run()              #启动socket

3.同级编写页面

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>我是主页</h1>
</body>
</html>

Python使用Flask简单快速入门

4.启动

Python使用Flask简单快速入门

Python使用Flask简单快速入门

Python使用Flask简单快速入门

相关文章: