Skip to content

Instantly share code, notes, and snippets.

@reinaldons
Created December 26, 2013 19:30
Show Gist options
  • Save reinaldons/8137667 to your computer and use it in GitHub Desktop.
Save reinaldons/8137667 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import cgi
import urllib
import urllib2
import sys
import cgitb
cgitb.enable()
def post_activemq(sent_data):
sys.stderr.write(sent_data)
arguments = cgi.FieldStorage()
data = urllib.urlencode({'email': arguments['email'].value,
'temp_queue': 'temp_queue'})
try:
response = urllib2.urlopen("http://a/", data)
html = response.read()
except urllib2.HTTPError, e:
sys.stderr.write(str(e.code))
post_activemq(data)
except urllib2.URLError, e:
sys.stderr.write(str(e.reason))
post_activemq(data)
print "Content-type: application/json;charset=utf-8"
#print "Status: 200 Ok"
print
print "{'result': 'email enviado!'}"
# FIXME post_activemq deveria chamar
# response = urllib2.urlopen("http://b", data)
# html = response.read()
# print html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment