title: Can't seem to figure out how to use response headers in Flask
body: <p>Hey guys idk why my code is not working. I forgot most of the stuff about response headers and how to use it and i suck at figuring out when to use dict and tuple etc.</p>
  
  <pre><code>from flask import Flask, jsonify, json, request, abort
  from flask_sqlalchemy import SQLAlchemy
  
  app = Flask(__name__)
  app.config.from_pyfile('Config.py')
  db = SQLAlchemy(app)
  response = {}
  
  class JsonModel(object): #Class for making objects JSON serializable
      def as_dict(self):
          return {c.name: getattr(self, c.name) for c in self.__table__.columns}
  
  class User(db.Model, JsonModel): #Class which is a model for the User table in the database
      User_ID = db.Column(db.Integer, primary_key = True)
      FirstName = db.Column(db.String(20))
      LastName = db.Column(db.String(20))
  
  def __init__(self,User_ID,FirstName, LastName):
      self.User_ID = User_ID
      self.FirstName = FirstName
      self.LastName = LastName
  
  class Todo(db.Model, JsonModel):    #Class which is a model for the Todo table in the database
      todo_ID = db.Column(db.Integer, primary_key = True)
      UserID = db.Column(db.Integer, db.ForeignKey("user.User_ID"))
      details = db.Column(db.String(30))
  
  def __init__(self, UserID, details):
      self.UserID = UserID
      self.details = details
  
  @app.route('/todo', methods = ['GET'])   #Uses GET method to return all information in the database.
  def index():
      return json.dumps([u.as_dict() for u in Todo.query.all()])
  
  @app.route('/todo/&lt;int:todo_ID&gt;', methods = ['GET'])
  def get(todo_ID):
      todo = Todo.query.get(todo_ID)
      response
      response['todo_ID']= todo.todo_ID
      response['UserID'] = todo.UserID
      response['details'] = todo.details
      response.status_code = 200
      response.headers['location'] = '/todo/{}'.format(todo.todo_ID)
      return response
  </code></pre>
  
  <p>WHen running this code I get the following error.</p>
  
  <pre><code>File "/home/muba/PycharmProjects/Work/Flaskapp.py", line 43, in get
      response.status_code = 200
  AttributeError: 'dict' object has no attribute 'status_code'
  127.0.0.1 - - [01/Mar/2017 21:29:27] "GET /todo/1 HTTP/1.1" 500 -
  </code></pre>
  
  <p>Can someone tell me whats wrong and also point me to some sort of tutorial. Only thing I can understand from this is that my response object at the top can't use status_code for some reason.</p>