-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathurl_runner.py
More file actions
35 lines (29 loc) · 968 Bytes
/
url_runner.py
File metadata and controls
35 lines (29 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import json
from config import DEBUG
def get(url, query_data=None, headers=None, return_json=False):
res = requests.get(url, params=query_data, headers=headers)
if DEBUG:
print res.status_code
if return_json is True:
return res.json()
else:
return res.text
def post(url, data=None, headers=None, return_json=False):
res = requests.post(url, data=json.dumps(data), headers=headers)
if return_json is True:
return res.json()
else:
return res.text
def put(url, data=None, headers=None, return_json=False):
res = requests.put(url, data=json.dumps(data), headers=headers)
if return_json is True:
return res.json()
else:
return res.text
def delete(url, data=None, headers=None, return_json=False):
res = requests.delete(url, data=json.dumps(data), headers=headers)
if return_json is True:
return res.json()
else:
return res.text