Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flask not binding to 0.0.0.0

Tags:

docker

flask

I have a very simple flask application that needs to be deployed using Docker.

Currently, I'm testing in my localhost and want the server to bind to 0.0.0.0 but when I run the application it still points to 127.0.0.1

    from flask import Flask, render_template
    from flask import jsonify
    app = Flask(__name__)


    @app.route("/")
    def main():
        return render_template('app.html')

if __name__ == '__main__':
    app.jinja_env.auto_reload = True
    app.config['TEMPLATES_AUTO_RELOAD'] = True
    app.run(debug=True)
    app.run(host='0.0.0.0')

Here is the startup message when I run the app -

* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 904-757-118
like image 267
user1050619 Avatar asked Oct 12 '25 20:10

user1050619


1 Answers

Here is what you should do:

if __name__ == '__main__':
    app.jinja_env.auto_reload = True
    app.config['TEMPLATES_AUTO_RELOAD'] = True
    app.run(host='0.0.0.0', debug=True)

multiple args is not passed by multiple method call.

like image 77
Andy Avatar answered Oct 14 '25 22:10

Andy