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)

 

相关文章:

  • 2021-05-30
  • 2021-11-29
  • 2021-11-17
  • 2021-11-04
  • 2021-09-19
  • 2021-05-24
猜你喜欢
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2021-12-26
  • 2021-05-13
相关资源
相似解决方案