forked from crash-override404/photofunia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
30 lines (23 loc) · 1.08 KB
/
utils.py
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
import sys
import base64
import requests
import urllib
class Utils:
"""docstring for Utils"""
def __init__(self):
self._session = requests.Session()
def urlEncode(self, url, path, params=[]):
try: # Works with python 2.x
return url + path + '?' + urllib.urlencode(params)
except: # Works with python 3.x
return url + path + '?' + urllib.parse.urlencode(params)
def optionsContent(self, url, data=None, headers=None):
return self._session.options(url, headers=headers, data=data)
def postContent(self, url, data=None, files=None, headers=None):
return self._session.post(url, headers=headers, data=data, files=files)
def getContent(self, url, headers=None):
return self._session.get(url, headers=headers, stream=True)
def deleteContent(self, url, data=None, headers=None):
return self._session.delete(url, headers=headers, data=data)
def putContent(self, url, data=None, headers=None):
return self._session.put(url, headers=headers, data=data)