2

I am trying to get started with Flask, and I get 404 Not Found error for the hello world program.

The program I use:

from flask import Flask
app = Flask(__name__)

@app.route('/')
@app.route('/index.html')
def hello_world():
    return 'Hello, World'

if __name__== '__main__':
    app.run(host='localhost')

then I run

$export FLASK_APP = minimal.py
$flask run

Which returns:

* Serving Flask app "minimal"
* Forcing debug mode on
* Restarting with stat
* Debugger is active!
* Debugger PIN 127-804-808
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

When I visit http://localhost:5000 or http://127.0.0.1:5000, I get:

Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

And my host file looks like this:

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

Any idea whats wrong? Thank you

Amulya K Murthy
  • 124
  • 2
  • 15
hasanzuav
  • 534
  • 5
  • 15

1 Answers1

0

Yeah, you can remove the error 404 not found in following ways: 1: You should write command netstat -a -b to check which port is not free or busy doing something or 2: write in your code app.run(port=4996) instead of app.run() which by default choose port no. 50000.