So when I run the following code, it gives me 2 IP's but both lead to a local network IP. How do I make it route to a public IP if possible?
OS: Windows 10 Python Version: Python 3.12.0 Flask Version: 3.0.2
from flask import Flask, request, Response
app = Flask(__name__)
@app.route('/', methods=['GET'])
def home():
return "Hey!"
@app.route('/webhook', methods=['POST'])
def respond():
print(request.json)
return Response(status=200)
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0")
Thanks
When you use host="0.0.0.0", Flask will listen on all network interfaces on your machine. You may want to use app.run(debug=True)
.
You need to use your public IP address. Usually, I'd recommend using a cloud server to configure its firewall securely. Still, if you want to use your home network, you'll have to log in to your router and set up port forwarding to forward incoming traffic on a specific port (usually port 80 for HTTP) to your local machine's private IP address.
You can log in to your router by doing an ipconfig
to get your default gateway's IP address. Then, you'll need to enter that IP into your browser. You usually can get your router's username/password from the router's sticker or manual. The rest is dependent on the router's model.