Why can't I change the host and port that my Flask app runs on?

前端 未结 5 578
自闭症患者
自闭症患者 2020-11-30 08:32

I want to change the host and port that my app runs on. I set host and port in app.run, but the flask run command still r

5条回答
  •  半阙折子戏
    2020-11-30 08:47

    When you run the application server using the flask run command, the __name__ of the module is not "__main__". So the if block in your code is not executed -- hence the server is not getting bound to 0.0.0.0, as you expect.

    For using this command, you can bind a custom host using the --host flag.

    flask run --host=0.0.0.0
    

    Source

提交回复
热议问题