python flask demo

1.安装pycharm  flask

2.查看帮助

#import requests;
from flask import Flask

#help(requests)
help(Flask)

3.demo 

from flask import Flask

app = Flask(__name__)

@app.route("/index")
def index():
    return "<h1 style='color:red'>Hello World</h1>"

@app.route('/test')
def hello_world():
    return 'hello world test'

if __name__ == "__main__":
    #app.run()  #默认端口 5000
    app.run(host='127.0.0.1',port=5001) # 指定端口,ip

  4.访问

http://127.0.0.1:5001/test

http://127.0.0.1:5001/index

 

posted on 2020-11-17 08:46  oktokeep  阅读(223)  评论(0编辑  收藏  举报