Flask 'hello World' Not Working
Solution 1:
I don't know why but when I change
app.run()
to
app.run(port=4996)
it starts working. No idea why the default port is throwing an error. Oh well.
Solution 2:
from flask importFlaskapp= Flask(__name__)
@app.route('/')
def index():
return'Hello World'if__name__== '__name__':
app.run()
app.run(port=5000)
Solution 3:
For Windows machines you can use the command in cmd:
set FLASK_APP=python_file.py
flask run
Solution 4:
Some other process is running on port 5000. It may be you still have an old Flask process running, with broken code. Or a different web server altogether is running on that port. Shut down that process, or run on a different port.
You can switch to using a different port with the port
argument to app.run()
:
app.run(port=8080)
If you can't figure out what process is still bound to port 5000, use the Windows Resource Monitor or run netstat -a -b
from a command line. See How can you find out which process is listening on a port on Windows?
Solution 5:
I think you are trying to copy the route generated through your flask program in cmd by pressing ctrl+c which quits your running flask program . i was also doing the same.just try to type the route generated by your flask program on your browser . it will definitely resolve your problem.
Post a Comment for "Flask 'hello World' Not Working"