I'm new to the GAE (Python) and really need some help getting my head around serving images from the Datastore and accesing them within client-side Javascript.
I've been folling Google's tutorial here: Serving Dynamic Images with Google App Engine (Python)
Let's say I have the data object to store some images
class Default_tile(db.Model)
name = db.StringProperty()
image = db.BlobProperty(default=None)
Is the correct code to add an image to the above database this?:
default_tile = Default_tile()
default_tile.name = "grass"
default_tile.image = db.Blob(urlfetch.Fetch("http://www.bbc.com/grass.png").content)
default_tile.put()
No lets say I have the following code on the client side javascript:
var image = new Image();
image.onload = function() {
context.drawImage(image, 69, 50);
};
imageObj.src = ***how to I get the image, named grass, from the Datastore***
So my question is how would I get the image?
Ideally, I would like to just use imageObj.src = /images/grass
Thanks for your help.