Skip to content

Instantly share code, notes, and snippets.

@drewlesueur
Created July 1, 2010 17:12
Show Gist options
  • Save drewlesueur/460250 to your computer and use it in GitHub Desktop.
Save drewlesueur/460250 to your computer and use it in GitHub Desktop.
Heatmap poxy
import base64
from google.appengine.api import datastore
from google.appengine.api import datastore_errors
from google.appengine.api import datastore_types
import hashlib
data = req.get("data")
if len(data) > 0:
m = hashlib.md5()
m.update(data)
the_md5 = m.hexdigest()
ent = datastore.Entity(kind="heatmap_image", name=the_md5)
ent['data'] = data
datastore.Put(ent)
echo("http://clstff.appspot.com/wave/googlewave.com%21w%2BaXCOteWYA?image=" + the_md5)
image = req.get("image")
if len(image) > 0:
key = datastore.Key.from_path("heatmap_image", image)
try:
ent = datastore.Get(key)
data = ent['data']
data = base64.b64decode(data)
resp.headers["Content-Type"] = "image/png"
echo(data)
except datastore_errors.EntityNotFoundError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment