Exemplo n.º 1
0
  def post(self):
    req = self.request

    creator = users.get_current_user().email()
    template_name = sanitize.remove_tags(req.get('template_name'))
    original_image_data = req.get('image_data')

    if not template_name:
      self.error(400)
      return

    existing_template = MemeTemplate.get_by_key_name(template_name)
    if existing_template:
      self.error(400)
      return

    (image_data, width, height) = images.create_image(original_image_data)
    (thumbnail_image_data, _, _) = images.create_thumbnail_image(original_image_data)

    meme_template = MemeTemplate(
      key_name=template_name,
      creator=creator,
      image_data=db.Blob(image_data),
      thumbnail_image_data=db.Blob(thumbnail_image_data),
      name=template_name,
      height=height,
      width=width)
    key = meme_template.put()

    # This should probably redirect to create meme.
    self.redirect('/meme?template_name=' + key.name())
Exemplo n.º 2
0
def insert_meme(creator, listed, template_name, original_image_data, text):
  (image_data, width, height) = images.create_image(original_image_data)
  (thumbnail_image_data, _, _) = images.create_thumbnail_image(original_image_data)

  key_name = generate_meme_key_name()

  meme = Meme(
    key_name=key_name,
    creator=creator,
    listed=listed,
    image_data=db.Blob(image_data),
    thumbnail_image_data=db.Blob(thumbnail_image_data),
    template_name=template_name,
    text=text,
    height=height,
    width=width)
  return meme.put()