title: How to display pdf blob from Google App Engine using Python
body: <p>My first question on StackOverflow . . .</p>
  
  <p>In a Google App Engine application using python, I'm trying to display a small pdf image in-line with html on a page.</p>
  
  <p>I have a small class, written like this:</p>
  
  <pre><code>class modelReport(db.Model):
      Applicant = db.StringProperty()
      Reportblob = db.BlobProperty()
  </code></pre>
  
  <p>A small form is used to Upload the image and Submit the image to the following handler:</p>
  
  <pre><code>class UploadResults(webapp.RequestHandler):
      def post(self):
          m = modelReport()
          m.Applicant = self.request.get("txtApplicantName")
          Reportblob = self.request.get("file")
          m.Reportblob = db.Blob(Reportblob)
          m.put()
  </code></pre>
  
  <p>I'm using the following code to display the image and the name of the Applicant:</p>
  
  <pre><code>class RetrieveResults(webapp.RequestHandler):
      def get(self):
          self.response.out.write('''
          &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
          &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="em"&gt;
          &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="application/pdf" /&gt;
          &lt;title&gt;Results Page&lt;/title&gt;
          &lt;/head&gt;
          &lt;body&gt;
          ''')
          reports = db.GqlQuery('SELECT * FROM modelReport')
          for report in reports:
              self.response.out.write('&lt;/p&gt;&lt;b&gt;%s&lt;/b&gt; report is:' % report.Applicant)
              self.response.out.write("&lt;div&gt;&lt;img src='img?img_id=%s'&gt;&lt;/img&gt;" % report.key())
          self.response.out.write('''
          &lt;/body&gt;&lt;/html&gt;
          ''')
  </code></pre>
  
  <p>When using the development server Datastore Viewer, I can see new 'modelReport' entities that list Key, Write Ops, ID, Key Name, Applicant, and Reportblob.</p>
  
  <p>Issue is output lists the Applicant and then displays a small blue box with a "?" in the middle like it can't find the image file . . . And, the development server log console shows 404 errors:</p>
  
  <pre><code>INFO..."GET /retrieve_results/all_results HTTP/1.1" 200 -
  INFO..."GET /retrieve_results/img?img_id=ag...Aww HTTP/1.1" 404 -
  INFO..."GET /retrieve_results/img?img_id=ag...BQw HTTP/1.1" 404 -
  INFO..."GET /retrieve_results/img?img_id=ag...Bgw HTTP/1.1" 404 -
  </code></pre>
  
  <p>I thought for awhile that I may be useing the wrong 'Content Type' header, but similar code using Apache web server displays the text and image just fine.</p>
  
  <p>Seems like I may be making empty blobstore attributes "Reportblob", but I don't know how to verify or debug.</p>
  
  <p>Any or all help fixing GAE code would be greatly appreciated.</p>