I would like to set a list of hosts (IPs) on which my Flask server can listen on so that if the main Ethernet port blows up there is the other one that can support the traffic (kind of simple failover).
In my case I have a NIC with 4 ports and only 2 of them can be used by flask, the others must stay private (therefore I cannot set host='0.0.0.0')
For example this is the current configuration:
...
app = Flask(__name__, instance_relative_config=True)
app.run(debug=False, host='192.168.1.10', port=5000)
and I would like to get the following:
...
app = Flask(__name__, instance_relative_config=True)
app.run(debug=False, host='192.168.1.10,192.168.1.11', port=5000)
Do you have any idea?
Many thanks in advance
Flask's built-in server isn't supposed to be used for anything other than development work:
To get the behavior you want, use a more robust WSGI server like gunicorn, which would allow you to listen on multiple addresses like this (assuming your code lives in
app.py):