1.下载flask模块:
pip installer flask
2.新建web文件输入代码。
from flask import Flask
app=Flask(__name__)
@app.route("/info")
def index():
return "中国电信"
if __name__ == '__main__':
app.run()
3.运行
* Serving Flask app 'web'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
127.0.0.1 - - [16/Sep/2022 09:31:52] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [16/Sep/2022 09:31:52] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [16/Sep/2022 09:31:57] "GET /info HTTP/1.1" 200 -
4.效果