Just another WordPress.com site

I created something simliar to what you want to achieve.. Hope this helps

image.py

    import os
    from google.appengine.ext import db
    from google.appengine.ext import webapp
    from google.appengine.ext.webapp import template
    from google.appengine.ext.webapp.util import run_wsgi_app
    class Profile(db.Model):
                    image=db.BlobProperty()
    class disp_image(webapp.RequestHandler):       
                    def get(self): 
                        key = self.request.get('key')
                        image = Profile.get(key)
                        self.response.headers['Content-Type'] = "image/png"
                        return self.response.out.write(image.image)
    class MainPage(webapp.RequestHandler):
        def get(self):
            image = self.request.get('image')
            pro=Profile()
            if image:   
                pro.image = db.Blob(image)
                import logging
                logging.info('persisted')
                pro.put()
            prof=Profile().all()

            return self.response.out.write(template.render('view.html',{'prof':prof}))
        def post(self):
            return MainPage.get(self)
    application = webapp.WSGIApplication([
      ('/', MainPage),
      ('/disp', disp_image)
    ], debug=True)
    def main():
      run_wsgi_app(application)
    if __name__ == '__main__':
      main()

view.html

  {% for prof in prof %}  {% endfor %} 

app.yaml

    application: sample-app
    version: 1
    runtime: python
    api_version: 1

    handlers:
    - url: /.*
      script: image.py
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: