Created
December 26, 2013 19:30
-
-
Save reinaldons/8137667 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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 "{'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