[flask] hello

flask hello

0.hello.py

from flask import Flask
app = Flask(__name__)

@app.route('/')
def index():
    return '<h1>hello world.</h1>'

if __name__ == '__main__':
    app.run(debug=True)

运行起来就是python hello1.py

python hello1.py                                                                                                                                                   !10032
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger pin code: 270-940-657

1.增加一个manager

类似django的运行方式。需要的步骤也很少。
需要引入一个ext.script的包.

from flask.ext.script import Manager
manager = Manager(app)
# ...
if __name__ == '__main__':
manager.run()

猜你喜欢

转载自blog.csdn.net/aca_jingru/article/details/51679627