The question in short
How do you run a simple Flask-based website visible to the internet, from a host PC which is accessing the internet from a wireless router?
Question details
I would like to make a flask application visible to the internet, as per Quickstart Guide.
If I launch the simple Flask app below, it becomes accessible from a computer on the same network as the host pc, but not from a device connected through the internet through another network.
The problem is similar to the one discussed here and here, with the added element that running from a home pc seems to suggest that external connections point to the xx port of the router, not to the xx port of the host pc, as is suggested in the comments in this post.
What I did
Referencing the code below, here's what I did:
The result is that "The webpage is not available".
Has anybody encountered the same problem? Is this a router issue?
Reference Flask app
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run(host= '0.0.0.0', port=9000, debug=False)
The basic setup will be to create a rule which will forward request to port 80 and/or port 443 to a destined host in your local network.
Example create NAT(address translation) and port forwarding rule to forward inbound HTTP/S requests to your local network host running your python application.
For example:
app.run(host= '192.168.0.58', port=9000, debug=False)
Your NAT rule should target 192.168.0.58 on port 9000.