Reputation: 127
I set Firewall Rule for my local google compute instance at host '0.0.0.0' and port 7000.
And I executed python server.py
, it was running on https://0.0.0.0:7000
but when I enter https://external-ip:7000
on my local browser it did not work.
So how can I run flask on google compute engine and open in my local computer browser?
server.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World’
if __name__ == '__main__':
app.run(debug=1,port=7000,host='0.0.0.0')
Upvotes: 1
Views: 3195
Reputation: 1051
A few things:
Check your VPC firewall:
https://cloud.google.com/vpc/docs/firewalls
In your terminal, see if connections are working locally on that host by issuing:
telnet localhost 7000
If it connects then it's either firewall or the below.
If you're running on https, you'll probably need to have something along the lines of:
context = ('host.crt', 'host.key')
app.run(host='0.0.0.0',port='7000', ssl_context=context)
Lastly, it's https:// not \
Upvotes: 3