moved httpHeaders variable around to work
This commit is contained in:
@@ -13,16 +13,14 @@ import mysql.connector
|
|||||||
|
|
||||||
def request(resource, seafileURL, seafileToken, method='GET', data=None, dataIsJson=True):
|
def request(resource, seafileURL, seafileToken, method='GET', data=None, dataIsJson=True):
|
||||||
if data is None:
|
if data is None:
|
||||||
data = ''
|
httpHeaders = {'Accept': 'application/json; charset=utf-8; indent=4', 'Authorization': 'Token {0}'.format(seafileToken)}
|
||||||
|
data = ''
|
||||||
else:
|
else:
|
||||||
if dataIsJson:
|
if dataIsJson:
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
httpHeaders = {'Content-type': 'application/json', 'Accept': 'application/json; charset=utf-8; indent=4', 'Authorization': 'Token {0}'.format(seafileToken)}
|
httpHeaders = {'Content-type': 'application/json', 'Accept': 'application/json; charset=utf-8; indent=4', 'Authorization': 'Token {0}'.format(seafileToken)}
|
||||||
else:
|
else:
|
||||||
if method == "POST":
|
httpHeaders = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'application/json; charset=utf-8; indent=4', 'Authorization': 'Token {0}'.format(seafileToken)}
|
||||||
httpHeaders = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'application/json; charset=utf-8; indent=4', 'Authorization': 'Token {0}'.format(seafileToken)}
|
|
||||||
else:
|
|
||||||
httpHeaders = {'Accept': 'application/json; charset=utf-8; indent=4', 'Authorization': 'Token {0}'.format(seafileToken)}
|
|
||||||
url = '{0}/api/v2.1/{1}'.format(seafileURL, resource)
|
url = '{0}/api/v2.1/{1}'.format(seafileURL, resource)
|
||||||
logger.debug('Request URL: {0}'.format(url))
|
logger.debug('Request URL: {0}'.format(url))
|
||||||
logger.debug('Request Method: {0}'.format(method))
|
logger.debug('Request Method: {0}'.format(method))
|
||||||
|
|||||||
Reference in New Issue
Block a user