1 2 3 4 5 6 7 8 9 10 11 12 13 |
import httplib def put_message(archive_name, file_obj): connection = httplib.HTTPConnection('localhost', 8435) connection.request('POST', '/archive/%s' % archive_name, file_obj.read()) response = connection.getresponse() data = response.read() if response.status == httplib.BAD_REQUEST: raise Exception('wtf') elif response.status == httplib.CREATED: return else: raise Exception('!!') |