Ricardo Tovar
Ricardo Tovar

Reputation: 87

It does not recognize the route /greeting

I'm new to flask, I'm trying to do a rest api, but when creating my route it doesn't recognize it for me. I have imported flask and python 3.8.

from products import products
from flask import Flask

@app.route('/greeting')
def greeting():
return 'hi'


if __name__ == '__main__':
app.run(debug=True, port=4000)

enter image description here

Upvotes: 0

Views: 36

Answers (1)

KcH
KcH

Reputation: 3502

You need to create the instance of the Flask class

app = Flask(__name__)

A minimal Flask application looks something like this:

from flask import Flask
app = Flask(__name__)

@app.route('/greeting')
def hello_world():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run(debug=True, port=4000)

Now you could see it running at:

* Running on http://127.0.0.1:4000/

Access the greeting as http://127.0.0.1:4000/greeting

For more info read this

Upvotes: 1

Related Questions