Flask 服务器设置host=0.0.0.0之后外部仍然无法访问, 使用命令python *.py run启动OK

IP设置成0.0.0.0,还是不能外部访问
if __name__ == '__main__':
    app.run(host="0.0.0.0", port=5000, debug=True)

 

使用的Pycharm IDE,使用的三角号运行的Flask程序,启动后,显示信息仍然是127.0.0.1:5000

 * Serving Flask app "app.py"
 * Environment: development
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

 

百度一下,发现有IDE造成的问题,改用命令行运行Flask程序,之后正常了,可以外部访问了

(venv) D:\pycharm\sensor_test>python app.py
 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 808-650-231
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

 

posted @ 2019-04-19 16:30  静静别跑  阅读(5746)  评论(0编辑  收藏  举报