'Simple Flask app runs but page will not load
So last night I closed terminal without closing my flask app or deactivating my venv. I think maybe this is the cause of the issue but none of my googling has yielded results.
When I run the flask app I get this in the terminal:
* Serving Flask app "app" (lazy loading)
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 178-606-161
I have the following view function:
@app.route('/')
def index():
return render_template('index.html')
When I try to load the page in a browser I just get a spinning icon. No error page. Nothing. Just a loading icon.
I am running the app inside my venv. I've tried deleting and recreating my venv. It was working fine yesterday, and with no changes it is now not working.
Solution 1:[1]
Maybe you can change a port to run your app.I have encountered the same problem.Maybe the process of port 5000 is still in zombie state?
flask run --port=6000
Solution 2:[2]
Changing the port didn't work. I ended up uninstalling and reinstalling Ubuntu. Worked fine after that.
Solution 3:[3]
I had the same issue, possibly associated with Docker cleanup I did earlier. Running curl -i http://127.0.0.1:5000/
doesn't resolve, and port 6000 doesn't work for me, but using 5XXX fixed it:
flask run --port=5050
Solution 4:[4]
It Happens to me once I mistakenly duplicate a callback function. So there were 2 callback functions for a single page that have the same inputs and outputs leading to the same situation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | weijiang1994 |
Solution 2 | JimmyCode |
Solution 3 | acute_triceratops |
Solution 4 | Kasun Vimukthi Jayalath |