title: Displaying Blob Images in Python (App Engine)
body: <p>I am unable to get the image to display on the page. I can store it just fine.</p>
  
  <p>These are the handlers:</p>
  
  <pre><code>class disp_image(webapp.RequestHandler):
      def get(self):
          key = self.request.get('key')
          image = Images.get(key)
          if image:
              self.response.headers['Content-Type'] = "image/png"
              return self.response.out.write(images.image)
          else:
              self.response.headers['Content-Type'] = "image/png"
              return self.response.out.write("/static/unknown.gif")
  
  class Profile(MainHandler):
      def get(self):      
          if self.user:
              self.render('profile.html', username = self.user.name, email = self.user.email, first_name = self.user.first_name, last_name = self.user.last_name, country = self.user.country, prov_state = self.user.prov_state, city_town = self.user.city_town)
          else:
              self.redirect('/register')
  
  class Change_Profile_Image(MainHandler):
      def get(self):
          if self.user:
              self.render('change_profile_image.html', username = self.user.name, firstname=self.user.first_name)
          else:
              self.render('change_profile_image.html')
  
      def post(self):
          images = Images()
          imageupl = self.request.get('img')
          images.image = db.Blob(imageupl)
          images.put()
          self.redirect('/profile')
  </code></pre>
  
  <p>db stuff is a follows:</p>
  
  <pre><code>class Images(db.Model):
      image = db.BlobProperty()
  
  class User(db.Model):
      name = db.StringProperty(required=True)
      pw_hash = db.StringProperty(required=True)
      email = db.StringProperty(required=True)
      first_name = db.StringProperty()
      last_name = db.StringProperty()
      country = db.StringProperty()
      prov_state = db.StringProperty()
      city_town= db.StringProperty()
      clan= db.StringProperty()
      handle= db.StringProperty()
  </code></pre>
  
  <p>The form:</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" method="post"&gt;
         &lt;input type="file" name="img" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My template substitution bit of code:</p>
  
  <pre><code>&lt;img src="/disp?key={{image}}" /&gt;&lt;/img&gt;
  </code></pre>