Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask access from different devices

Is there a way to generate a specific IP address or make a specific site of flask http://127.0.0.1:5000/ site which runs locally, to access the web-app made using flask from different device as by default it runs locally and under http://127.0.0.1:5000/ but,i want to access it from different devices.If,there's a way please help

like image 952
Gautam Goyal Avatar asked Oct 19 '25 10:10

Gautam Goyal


1 Answers

refer first to this doc (section Externally Visible Server) on how to expose your local Flask app to make it accessible from trusted devices in your network for testing purposes.

$(venv) flask run --host=0.0.0.0

or in your app.py

from flask import Flask
[..]
app = Flask(__name__)
[..]
if __name__ == "__main__":
   app.run(host="0.0.0.0", port=5000, debug=True)

and then :

$(venv) python app.py

but if it happens and you got this error dial tcp 0.0.0.0:5000: connect: connection refused then try to use the local ip address (192.168.x.y instead of 0.0.0.0) of the machine hosting your Flask app. you may find this thread usefull

like image 64
cizario Avatar answered Oct 22 '25 02:10

cizario



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!