Skip to content

Instantly share code, notes, and snippets.

@maetl
Created May 22, 2010 19:37
Show Gist options
  • Save maetl/410303 to your computer and use it in GitHub Desktop.
Save maetl/410303 to your computer and use it in GitHub Desktop.
class ApiHandler(webapp.RequestHandler):
def check_uploaded_picture(self):
if not self.check_api_key():
self.error_response(401, API_ERROR_UNAUTHORIZED)
return False
if not self.request.get('picture'):
self.error_response(400, API_ERROR_MISSING)
return False
if not self.check_picture_type(self.request.POST['picture']):
self.error_response(400, API_ERROR_INVALID)
return False
return True
def check_picture_type(self, picture):
return picture.type in ['image/jpeg', 'image/png', 'image/gif']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment