I am unable to get the image to display on the page. I can store it just fine.
These are the handlers:
class disp_image(webapp.RequestHandler):
def get(self):
key = self.request.get('key')
image = Images.get(key)
if image:
self.response.headers['Content-Type'] = "image/png"
return self.response.out.write(images.image)
else:
self.response.headers['Content-Type'] = "image/png"
return self.response.out.write("/static/unknown.gif")
class Profile(MainHandler):
def get(self):
if self.user:
self.render('profile.html', username = self.user.name, email = self.user.email, first_name = self.user.first_name, last_name = self.user.last_name, country = self.user.country, prov_state = self.user.prov_state, city_town = self.user.city_town)
else:
self.redirect('/register')
class Change_Profile_Image(MainHandler):
def get(self):
if self.user:
self.render('change_profile_image.html', username = self.user.name, firstname=self.user.first_name)
else:
self.render('change_profile_image.html')
def post(self):
images = Images()
imageupl = self.request.get('img')
images.image = db.Blob(imageupl)
images.put()
self.redirect('/profile')
db stuff is a follows:
class Images(db.Model):
image = db.BlobProperty()
class User(db.Model):
name = db.StringProperty(required=True)
pw_hash = db.StringProperty(required=True)
email = db.StringProperty(required=True)
first_name = db.StringProperty()
last_name = db.StringProperty()
country = db.StringProperty()
prov_state = db.StringProperty()
city_town= db.StringProperty()
clan= db.StringProperty()
handle= db.StringProperty()
The form:
<form enctype="multipart/form-data" method="post">
<input type="file" name="img" />
</form>
My template substitution bit of code:
<img src="/disp?key={{image}}" /></img>