Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "app.run(host='0.0.0.0') " mean in Flask [duplicate]

I am reading the Flask documentation. I was told that with app.run(host='0.0.0.0'), I could make the server publicly available.

What does it mean ? How can I visit the server in another computer (just localhost:5000 in my own computer) ?

like image 542
Ding Avatar asked Aug 09 '15 13:08

Ding


People also ask

What is app run in flask?

The flask run command is the preferred way to start the development server. Never use this command to deploy publicly, use a production WSGI server such as Gunicorn, uWSGI, Waitress, or mod_wsgi. As of Flask 2.2, use the --app option to point the command at your app. It can point to an import name or file name.

Why does running the flask dev server run itself twice?

The reason for this is that due to how the reload mechanism works there are some bizarre side-effects (like executing certain code twice...)

What is the default host port and port of flask?

The default value is 5000 or it is the port number set in the SERVER_NAME config variable.


1 Answers

To answer to your second question. You can just hit the IP address of the machine that your flask app is running, e.g. 192.168.1.100 in a browser on different machine on the same network and you are there. Though, you will not be able to access it if you are on a different network. Firewalls or VLans can cause you problems with reaching your application. If that computer has a public IP, then you can hit that IP from anywhere on the planet and you will be able to reach the app. Usually this might impose some configuration, since most of the public servers are behind some sort of router or firewall.

like image 118
ipinak Avatar answered Sep 19 '22 06:09

ipinak