1import requests
2
3headers = {
4 'Content-type': 'application/json',
5}
6
7data = '{"text":"Hello, World!"}'
8
9response = requests.post('https://hooks.slack.com/services/asdfasdfasdf', headers=headers, data=data)
1import shlex
2cmd = '''curl -X POST -d '{"nw_src": "10.0.0.1/32", "nw_dst": "10.0.0.2/32", "nw_proto": "ICMP", "actions": "ALLOW", "priority": "10"}' http://localhost:8080/firewall/rules/0000000000000001'''
3args = shlex.split(cmd)
4process = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
5stdout, stderr = process.communicate()
1import requests
2res = requests.get('https://stackoverflow.com/questions/26000336')
1url = 'http://example.tld'
2payload = { 'key' : 'val' }
3headers = {}
4res = requests.post(url, data=payload, headers=headers)
1import pycurl
2import StringIO
3
4response = StringIO.StringIO()
5c = pycurl.Curl()
6c.setopt(c.URL, 'https://www.googleapis.com/qpxExpress/v1/trips/search?key=mykeyhere')
7c.setopt(c.WRITEFUNCTION, response.write)
8c.setopt(c.HTTPHEADER, ['Content-Type: application/json','Accept-Charset: UTF-8'])
9c.setopt(c.POSTFIELDS, '@request.json')
10c.perform()
11c.close()
12print response.getvalue()
13response.close()
14