Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\Scripts\flask.exe\__main__.py", line 7, in <module>
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\flask\cli.py", line 1105, in main
    cli.main()
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\click\decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\flask\cli.py", line 953, in run_command
    raise e from None
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\flask\cli.py", line 937, in run_command
    app: WSGIApplication = info.load_app()
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\flask\cli.py", line 341, in load_app
    app = locate_app(import_name, None, raise_if_not_found=False)
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\flask\cli.py", line 247, in locate_app
    __import__(module_name)
  File "C:\Users\alexa\Desktop\RESTQuiz\questionnaires\__init__.py", line 2, in <module>
    import questionnaires.views
  File "C:\Users\alexa\Desktop\RESTQuiz\questionnaires\views.py", line 3, in <module>
    from .models import Questionnaire, Question
  File "C:\Users\alexa\Desktop\RESTQuiz\questionnaires\models.py", line 5, in <module>
    class Questionnaire(db.model):
  File "C:\Users\alexa\Desktop\RESTQuiz\venv\lib\site-packages\flask_sqlalchemy\extension.py", line 1008, in __getattr__
    raise AttributeError(name)
AttributeError: model. Did you mean: 'Model'?The following text is a Git repository with code. The structure of the text are sections that begin with ----, followed by a single line containing the file path and file name, followed by a variable amount of lines containing the file contents. The text representing the Git repository ends when the symbols --END-- are encounted. Any further text beyond --END-- are meant to be interpreted as instructions using the aforementioned Git repository as context.
----
app.py
from flask import Flask
app = Flask(__name__)
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
----
models.py

from flask import Flask, request, jsonify, render_template, redirect, url_for
from .app import db

class Questionnaire(db.model):
  id = db.Column(db.Integer, primary_key=True)
  name = db.Column(db.String(80))
  
  def __init__(self, name):
    self.name = name
    
  def __repr__(self):
    return '<Questionnaire %r>' % self.name
  
  def to_json(self):
    json =  {
      'id': self.id,
      'name': self.name
    }
    return json
  
class Question(db.model):
  id = db.Column(db.Integer, primary_key=True)
  questionTYPE = db.Column(db.String(80))
  questionnaire_id = db.Column(db.Integer, db.ForeignKey('questionnaire.id'))
  questionnaire = db.relationship('Questionnaire', backref=db.backref('questions', lazy='dynamic'))
----
views.py
from flask import abort, jsonify, make_response, request, url_for
from.app import app
from .models import Questionnaire, Question

def make_public_questionnaire(questionnaire):
  new_questionnaire = {}
  for field in questionnaire:
    if field == 'id':
      new_questionnaire['uri'] = url_for('get_questionnaire', questionnaire_id = questionnaire['id'],
                                  _external = True)
    else:
      new_questionnaire[field] = questionnaire[field]
  return new_questionnaire

@app.route('/questionnaires/api/v1.0/questionnaires', methods=['GET'])
def get_questionnaires():
  return jsonify(questionnaires=[make_public_questionnaire(q) for q in Questionnaire.query.all()])




----
__init__.py
from .app import app
import questionnaires.views
import questionnaires.models
--END--