python - Vagrant, Flask — App not running on 10.10.10.10, 127.0.0.1 -
i'm running app on local box via vagrant. python/flask app launches , prints:
* running on http://127.0.0.1:5000/ * restarting reloader
i found https://github.com/makersquare/student-dev-box/wiki/using-vagrant-for-development#testing-web-based-applications-in-vagrant suggests vagrant apps run on 10.10.10.10
(not 127.0.0.1
), when navigate ip address (port 5000), same result: "this webpage not available".
question: app running, on ip address? can't seem find it. need modify configuration files?
thanks in advance.
there many ways how run flask web app on virtual machine (managed vagrant). think following approach quite flexible, because don't have deal different ip address. looks developing on host machine.
there 2 things need configure. in vagranfile, need configure port forwarding.
vagrant.configure(2) |config| # use default box config.vm.box = "ubuntu/trusty64" # forward port guest machine:5000 -> host machine:5000 # port 5000 default flask web app config.vm.network "forwarded_port", guest: 5000, host: 5000 end
then, on virtual machine, should start flask app on ip 0.0.0.0
means web app serve ip address. more on topic -> flask doc section externally visible server
if __name__ == "__main__": app.run("0.0.0.0", debug=true)
that's it. should able connect http://localhost:5000
Comments
Post a Comment