title: Trying to serve image dynamically from GAE, getting 404
body: <p>My image isn't being served form the datastore, I am getting a 404 on the page where the image should be.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import cgi
  import datetime
  import urllib
  import wsgiref.handlers
  
  from google.appengine.ext import db
  from google.appengine.api import images
  from google.appengine.api import users
  from google.appengine.ext import webapp
  from google.appengine.ext.webapp.util import run_wsgi_app
  
  
  class PropUpload(db.Model):
    property_name = db.StringProperty()
    property_address = db.StringProperty()
    project_type = db.StringProperty()
    building_size = db.StringProperty()
    stories = db.StringProperty()
    space_available = db.StringProperty()
    per_leased = db.StringProperty()
    prop_image = db.BlobProperty()
    date = db.DateTimeProperty(auto_now_add=True)
  
  
  class MainPage(webapp.RequestHandler):
    def get(self):
      self.response.out.write("""&lt;!DOCTYPE html&gt;
              &lt;html lang="en"&gt;
                &lt;head&gt;
        &lt;somehtml&gt;""")
  
      display2 = db.Query(PropUpload)
      display2.order("-date")
      for dis in display2:
          self.response.out.write('&lt;div&gt;&lt;img src="img?img_id=%s"&gt;&lt;/img&gt;' % dis.key())
          self.response.out.write('&lt;h4&gt;Property Name: %s &lt;/h4&gt;&lt;br&gt;' % dis.property_name)
          self.response.out.write('&lt;div style="border-bottom: 1px solid #CCC;"&gt;Address: %s &lt;/div&gt;&lt;br&gt;' % dis.property_address)
          self.response.out.write('&lt;div style="border-bottom: 1px solid #CCC;"&gt;Type:  %s ft&lt;sup&gt;2&lt;/sup&gt;&lt;/div&gt;&lt;br&gt;' % dis.project_type)
          self.response.out.write('&lt;div style="border-bottom: 1px solid #CCC;"&gt;Stories:  %s &lt;/div&gt;&lt;br&gt;' % dis.stories)
  
      self.response.out.write("&lt;more html&gt;")
  
  
  class Image(webapp.RequestHandler):
    def get(self):
      img_id = self.request.get("img_id")
      dis = db.get(self.request.get("img_id"))
      if dis.prop_image:
        self.response.headers['Content-Type'] = "image/png"
        self.response.out.write(dis.prop_image)
      else:
        self.response.out.write("no image")
  
  
  class UploadPage2(webapp.RequestHandler):
    def get(self):
      self.response.out.write("""&lt;!DOCTYPE html&gt;
      &lt;form action="/upload2" enctype="multipart/form-data" method="post"&gt;
                          &lt;div&gt;&lt;label&gt;Property Name:&amp;nbsp&lt;/label&gt;&lt;/div&gt;
                          &lt;div&gt;&lt;textarea name="prop-name" rows="1" columns "100"&gt;&lt;/textarea&gt;&lt;/div&gt;
                          &lt;br&gt;&lt;br&gt;
                          &lt;div&gt;&lt;label&gt;Property Address:&amp;nbsp&lt;/label&gt;&lt;/div&gt;
                          &lt;div&gt;&lt;textarea name="address" rows="1" columns "100"&gt;&lt;/textarea&gt;&lt;/div&gt;
                          &lt;br&gt;&lt;br&gt;
                          &lt;div&gt;&lt;label&gt;Property Type:&amp;nbsp&lt;/label&gt;&lt;/div&gt;
                          &lt;div&gt;&lt;textarea name="prop-type" rows="1" columns "100"&gt;&lt;/textarea&gt;&lt;/div&gt;
                          &lt;br&gt;&lt;br&gt;
                          &lt;div&gt;&lt;label&gt;Building Size:&amp;nbsp&lt;/label&gt;&lt;/div&gt;
                          &lt;div&gt;&lt;textarea name="size" rows="1" columns "100"&gt;&lt;/textarea&gt;&lt;/div&gt;
                          &lt;br&gt;&lt;br&gt;
                          &lt;div&gt;&lt;label&gt;Stories:&amp;nbsp&lt;/label&gt;&lt;/div&gt;
                          &lt;div&gt;&lt;textarea name="stories" rows="1" columns "100"&gt;&lt;/textarea&gt;&lt;/div&gt;
                          &lt;br&gt;&lt;br&gt;
                          &lt;div&gt;&lt;label&gt;Space Available:&amp;nbsp&lt;/label&gt;&lt;/div&gt;
                          &lt;div&gt;&lt;textarea name="title" rows="2" columns "100"&gt;&lt;/textarea&gt;&lt;/div&gt;
                          &lt;br&gt;
                          &lt;div&gt;&lt;label&gt;Percent Leased:&lt;/label&gt;&lt;/div&gt;&lt;span&gt;
                          &lt;div&gt;&lt;textarea name="percent" rows="3" cols="100"&gt;&lt;/textarea&gt;&lt;/div&gt;&lt;br&gt;
                          &lt;div&gt;&lt;label&gt;Picture:&lt;/label&gt;&lt;/div&gt;
                          &lt;div&gt;&lt;input type="file" name="img"/&gt;&lt;/div&gt;
                          &lt;div&gt;&lt;label&gt;&lt;/label&gt;&lt;/div&gt;&lt;span&gt;
                          &lt;div&gt;&lt;input type="submit" value="Upload" /&gt;&lt;/div&gt;
                        &lt;/form&gt;""")
  
  
    def post(self):
      props = PropUpload()
      property_name = self.request.get('prop-name')
      property_address = self.request.get('address')
      property_type = self.request.get('prop=type')
      building_size = self.request.get('size')
      stories = self.request.get('stories')
      space_available = self.request.get('space')
      prop_image = self.request.get('img')
      per_leased = self.request.get('percent')
      props.property_name = property_name
      props.property_address = property_address
      props.property_type = property_type
      props.building_size = building_size
      props.stories = stories
      props.space_available = space_available
      props.prop_image = db.Blob(prop_image)
      props.per_leased = per_leased
      props.put()
      self.redirect('/upload2')
  
  
  application = webapp.WSGIApplication([
      ('/', MainPage),
      ('/upload2', UploadPage2),
      ], debug=True)
  
  
  def main():
    run_wsgi_app(application)
  
  if __name__ == '__main__':
    main()
  </code></pre>
  
  <p>Everything works fine, except for the 404, and I can't finding anything googling the issue.</p>
  
  <p>Thanks for the help, and sorry if I left anything out, I will edit anything in.</p>