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:5000python

* 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程序,以後正常了,能夠外部訪問了app

(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)
相關文章
相關標籤/搜索