flask安装

转载:https://www.cnblogs.com/lsdb/p/10488448.html

一:前提条件:

已经安装了Python3,本机环境是anaconda Python3.6

二:安装flask

conda install Flask

三:第一个应用程序

# 导入Flask类
from flask import Flask
# 实例化,可视为固定格式
app = Flask(__name__)

# route()方法用于设定路由;类似spring路由配置
@app.route('/')
def hello_world():
    return 'Hello, World!'

if __name__ == '__main__':
    # app.run(host, port, debug, options)
    # 默认值:host=127.0.0.1, port=5000, debug=false
    app.run()

四:访问刚刚执行的代码:

访问:http://127.0.0.1:5000/helloworld。结果如下图:

 

posted on 2019-08-09 11:15  吱吱了了  阅读(223)  评论(0)    收藏  举报

导航