入门例子
from flask import Flask app = Flask(__name__) @app.route(‘/hello.world‘) def check(): return ‘hello world!‘ if __name__ == ‘__main__‘: app.run(debug=False, host=‘0.0.0.0‘, port=80) #指定了费debug模式,外部可访问的服务器,端口
请求
$curl http://10.177.80.30:80/hello.world hello world!
错误案例
from flask import Flask app = Flask(__name__) @app.route(‘/hello.world‘) def check(): return 200 if __name__ == ‘__main__‘: app.run(debug=False, host=‘0.0.0.0‘, port=80)
注:返回值不可为整数
参考:http://docs.jinkan.org/docs/flask/quickstart.html
时间: 2024-11-06 06:49:41