For some reason, 127.0.0.1:5000(port 5000) is stuck displaying my old un-updated file.
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
return "Home page"
@app.route("/about")
def about():
return "About page"
if __name__ == "__main__":
app.run()
I changed the port and it worked fine. But, why is 5000 not updating when I change and run my code? I checked to see if multiple process were running, but none were.
Honestly, this is a noob question, but I can't seem to find anyone else who's had this problem.
To run the application, use the flask command or python -m flask . You need to tell the Flask where your application is with the --app option. As a shortcut, if the file is named app.py or wsgi.py , you don't have to use --app . See Command Line Interface for more details.
Make sure, you close the terminal and not press Ctrl + C. This will allow it to run in background even when you log out. To stop it from running , ssh in to the pi again and run ps -ef |grep nohup and kill -9 XXXXX where XXXX is the pid you will get ps command. Save this answer.
App Routing means mapping the URLs to a specific function that will handle the logic for that URL. Modern web frameworks use more meaningful URLs to help users remember the URLs and make navigation simpler. Example: In our application, the URL (“/”) is associated with the root URL.
Press CTR + C to end your server on the terminal and copy and paste this in the terminal to run Flask again
FLASK_DEBUG=1 flask run
This will set Debug mode: on
To set variable in powershell -
$env:FLASK_DEBUG=1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With