Search code examples
pythonflasklocalhostwifipython-3.7

I have set up a small flask webpage but in only runs on localhost while I would like to make it run on my local network python3.7


I have set up a small flask webpage but in only runs on localhost while I would like to make it run on my local network, how do I do that?


Solution

  • Just my 2 cents on this, I just did some research, there are many suggestions online...

    Adding a parameter to your app.run(), by default it runs on localhost, so change it to app.run(host= '0.0.0.0') to run on your machines IP address.

    Few other things you could do is to use the flask executable to start up your local server, and then you can use flask run --host=0.0.0.0 to change the default IP which is 127.0.0.1 and open it up to non local connections.

    The thing is you should use the app.run() method which is much better than any other methods.

    Hope it helps a little, if not good luck :)