Created
July 1, 2010 17:12
-
-
Save drewlesueur/460250 to your computer and use it in GitHub Desktop.
Heatmap poxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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