Configure Flask dev server to be visible across the network

前端 未结 14 2749
面向向阳花
面向向阳花 2020-11-21 05:57

I\'m not sure if this is Flask specific, but when I run an app in dev mode (http://localhost:5000), I cannot access it from other machines on the network (with

14条回答
  •  佛祖请我去吃肉
    2020-11-21 06:47

    If your cool app has it's configuration loaded from an external file, like in the following example, then don't forget to update the corresponding config file with HOST="0.0.0.0"

    cool.app.run(
        host=cool.app.config.get("HOST", "localhost"),
        port=cool.app.config.get("PORT", 9000)
    )            
    

提交回复
热议问题