sa125 sa125 - 3 months ago 59
Python Question

Flask - configure dev server to be visible across the network

I'm not sure if this is Flask specific, but when I run an app in dev mode (

), I cannot access it from other machines on the network (with
). With Rails in dev mode, for example, it works fine. I couldn't find any docs regarding the Flask dev server configuration. Any idea what should be configured to enable this?


Add a parameter to your By default it runs on localhost, change it to '') to run on your machines IP address.

Documented on the Flask site under "Externally Visible Server" on the Quickstart page:

Externally Visible Server

If you run the server you will notice that the server is only available from your own computer, not from any other in the network. This is the default because in debugging mode a user of the application can execute arbitrary Python code on your computer. If you have debug disabled or trust the users on your network, you can make the server publicly available.

Just change the call of the run() method to look like this:'')

This tells your operating system to listen on a public IP.