Please tell me how to connect to the website

Question:Below is the code I made using python flask. I want to use it to open a website, but no matter I use 0.0.0.0, 127.0.0.1:5000, or 0.0.0.0:5000, I can’t connect to the web page.

Repl link:https://replit.com/@Residual2023528/Python-Flask?s=app


Hey @Residual2023528!

Repls aren’t hosted locally on your computer, so for the time being you might want to access your website by changing this:

app.run(debug=True)

into this:

app.run(port='0.0.0.0', debug=True)

and access it via https://python-flask.residual2023528.repl.co. Be aware that the repl.co domains are being fully removed by January 1st, 2024. You may want to deploy your Repl.

3 Likes

Hey @Residual2023528!

I see your problem you don’t have a port or host, change your __main__ to this →

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)

It includes the host='0.0.0.0' and your port port=5000 (which is needed to get a Webview). I hope this helps!

2 Likes

Just as a note @Residual2023528, using debug=True is known to cause issues on Replit, and it’s recommended you remove it from your code.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.