![]() |
VOOZH | about |
By default, a Flask application runs on 127.0.0.1:5000, which makes it accessible only on the same machine. To access the application from other devices on the same network, the host IP address can be changed.
host parameter in app.run() is used to specify the IP address on which the application should run. Setting the host to a local network IP allows other devices on the same network to access the application.
Output
Now, the app will be accessible from other devices on the same network using 192.168.0.105:5000.
Instead of modifying the script, we can set the host and port directly when running the app from the terminal. Here are the steps:
1. Set the Flask app environment variable:
set FLASK_APP=app.py
2. Run the Flask app with a custom IP and port:
flask run --host=192.168.0.105 --port=5000
Output
We can make it accessible on a different IP by using the command "flask run --host=192.168.0.105 --port=5000".