I uploaded a Flask project that I prepared to a server of a windows computer. I can run the project over localhost on the computer I connect remotely. But I was asked to access the project from any computer with the IP and port address of the remote computer. What should I do for it?
Asked
Active
Viewed 386 times
1 Answers
0
You need to tell flask to run on all interfaces, either with:
flask run -h 0.0.0.0
Or if you're launching via app.run
, provide the host argument:
if __name__ == '__main__':
app.run(host='0.0.0.0')
Of course if your machine has several interfaces, you could provide the IP of the specific interface instead of 0.0.0.0
.
Bear in mind that the dev server is not meant for production. The above is fine if you want to access you're dev server remotely, but you'll probably want to run with something like gunicorn eventually, in which case provide the IP:port
combo as the bind
flag:
gunicorn --bind 0.0.0.0:5000 app:app

v25
- 7,096
- 2
- 20
- 36