Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flask object has no attribute get while following linode tutorial

Good morning,

Following the linode tutorial here to create a RESTful API
https://www.linode.com/docs/guides/create-restful-api-using-python-and-flask/

I keep getting an attribute error ‘Flask’ object has no attribute ‘get’

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Not sure what’s going on because I’m following the tutorial precisely.

from flask import Flask

application = Flask(__name__)

in_memory_datastore = {
   "COBOL" : {"name": "COBOL", "publication_year": 1960, "contribution": "record data"},
   "ALGOL" : {"name": "ALGOL", "publication_year": 1958, "contribution": "scoping and nested functions"},
   "APL" : {"name": "APL", "publication_year": 1962, "contribution": "array processing"},
}

@application.get('/programming_languages')
def list_programming_languages():
   return {"programming_languages":list(in_memory_datastore.values())}

>Solution :

You’re probably running an older version of Flask (v2.0.x or below).

Flask added @application.get feature in v2.1.x branch (check documentation here).

For older flask versions use @application.route('/programming_languages', methods=['GET']). Documentation here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading