折腾:
期间,在:
之后,再去验证,搞清楚,如何让Flask运行起来。
然后接着尝试去折腾Flask:
Quickstart — Flask Documentation (0.11)
用vi hello.py
(SIPEvents) SIPEvents cat hello.py from flask import Flask app = Flask(__name__) @app.route(‘/’) def hello_world(): return ‘Hello, World!’ (SIPEvents) SIPEvents pwd /root/SIPEvents |
(SIPEvents) SIPEvents ll total 4.0K -rw-r–r– 1 root root 109 Aug 15 20:53 hello.py (SIPEvents) SIPEvents pwd /root/SIPEvents (SIPEvents) SIPEvents export FLASK_APP=hello.py (SIPEvents) SIPEvents flask run * Serving Flask app “hello” * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) |
Deployment Options — Flask Documentation (0.11)
结果去访问:
结果出错:
然后去:
control+C去终止
再去:
(SIPEvents) SIPEvents flask run –host=0.0.0.0 * Serving Flask app “hello” * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) 121.238.252.151 – – [15/Aug/2016 20:57:58] “GET / HTTP/1.1” 200 – 121.238.252.151 – – [15/Aug/2016 20:57:58] “GET /favicon.ico HTTP/1.1” 404 – |
然后再去访问:
试试,就可以了:
-》
说明Flask是工作了
去加上debug参数:
(SIPEvents) SIPEvents export FLASK_DEBUG=1 (SIPEvents) SIPEvents flask run –host=0.0.0.0 * Serving Flask app “hello” * Forcing debug mode on * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger pin code: 353-795-063 |
然后去用浏览器去访问:
可以看到log输出:
121.238.252.151 – – [15/Aug/2016 20:59:48] “GET / HTTP/1.1” 200 – 121.238.252.151 – – [15/Aug/2016 20:59:55] “GET / HTTP/1.1” 200 – 121.238.252.151 – – [15/Aug/2016 20:59:55] “GET / HTTP/1.1” 200 – |
就说明Flask可以基本的工作了。
转载请注明:在路上 » [记录]CentOS中运行Flask服务器