Hello
I'm probably missing something fundamental but I cant find a solution
to serve images dynamically from the appengine datastore. I am
somewhat of a newbie, so i apologize for my naivity. I'm using Safari
& Mac & appengine dev environment & eclipse & pydev.
....I have a blob field, which contains an image i have successfully
loaded....
class Registration(db.Model):
subscriber = db.UserProperty(required=True)
picture = db.BlobProperty(required=False)
.......In my html file, where i want to display the image I have......
<div><img src='img?img_id="{{registrationkey}}"></img></div>
......When i view source this is populated with the key of the
datastore item containing the image...so far so good...
<div><img src='img?
img_id="agxsb3N0YW5kZm91bmRyEgsSDFJlZ2lzdHJhdGlvbhgBDA"></img></div>
..... and i have added Image to my list of handlers....although im not
sure how this helps...
application = webapp.WSGIApplication(
[('/', MainPage),
('/register',Register),
('/img',Image)
],
debug=True)
....I have created a handler for the img
class Image (webapp.RequestHandler):
def get(self):
strkey= self.request.get("img_id")
r = db.get(db.key(strkey))
logging.info("serving image %",strkey)
if r.picture:
self.response.headers['Content-Type'] = "image/png"
self.response.out.write(r.picture)
i.m sure that there is something wrong with it anyway, but my handler
never actually gets called, and the browser just stops displaying the
page at the <img> tag -
What Im missing firstly is how do you communicate that <img> needs to
use my handler called Image , and secondly what should be the syntax
for writing the image out once it does get called given that i am
using templates in my html?
Thank you for your help.
Bruce
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---