Skip to content

Instantly share code, notes, and snippets.

@zaach
Created September 22, 2008 20:58
Show Gist options
  • Save zaach/12160 to your computer and use it in GitHub Desktop.
Save zaach/12160 to your computer and use it in GitHub Desktop.
import os
import cgi
form = cgi.FieldStorage()
callback = form.getvalue('callback','')
json = '{ip: "'+cgi.escape(os.environ["REMOTE_ADDR"])+'"}'
if callback != '':
print 'Content-Type: application/javascript'
result = callback+'('+json+');'
else:
print 'Content-Type: application/json'
result = json
print ''
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment