Click here to Skip to main content
15,942,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using an online IDE to test a flask project, but whatever I do, I get a web page that gives localhost refused to connect error. It happens when I submit a form, and it is supposed to redirect to another page. Further more, I tried to run this on another online IDE, but still the same error. What could be wrong?

What I have tried:

I did everything right, setting host to 0.0.0.0, I tried every port from port 8000, port 8080 and port 5000. I even adjusted windows firewall settings to allow port 8000. I added if __name__ == '__main__': to app.run() but it still doesn't work.
Here is the code in question: https://replit.com/@roberttattorn/FlaskProject#main.py
Posted
Updated 24-Dec-21 12:14pm
v2
Comments
Richard MacCutchan 23-Dec-21 7:37am    
I do not think you can run using localhost via an online ide. You should install flask on your local system to test it properly.

1 solution

Well, I found a solution to this. It turned out, that the url provided in the form action section >http://localhost:8000/result should instead be /result so that it's a relative address instead of an absolute address.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900