Created
November 1, 2009 18:46
-
-
Save drewlesueur/223658 to your computer and use it in GitHub Desktop.
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
# Example (try uncommenting): | |
# resp.out.write("Hello! Your name: %s <hr />%s" % (req.get('name'), fetch('http://example.com').content)) | |
from google.appengine.ext.webapp import template | |
from google.appengine.api import urlfetch | |
import base64 | |
import urllib | |
language_engines = { | |
'php': 'http://scriptlets-engine.appspot.com/run.php', | |
'javascript': 'http://scriptlets-engine.appspot.com/javascript/', | |
'python': 'http://scriptlets-python.appspot.com/python/', | |
} | |
language = req.get("__language__") | |
engine = language_engines[language] | |
script = fetch(req.get("__code__")) | |
payload = dict(req.POST) | |
headers = dict(req.headers) | |
if headers.get('Content-Type'): | |
del headers['Content-Type'] | |
headers['Run-Code'] = base64.b64encode(script.code) | |
resp.out.write(urlfetch.fetch( | |
url='%s?%s' % (engine, self.request.query_string), | |
payload=urllib.urlencode(payload) if len(payload) else None, | |
method=req.method, | |
headers=headers).content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment