Skip to content

Commit

Permalink
more robust url handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pinae committed Feb 4, 2016
1 parent 0b2caae commit e4af10b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ def pull(self):
:return: base64 encoded data
:rtype: str
"""
request = requests.post(self.server_url + "ajax/read.php",
if self.server_url[-1] == "/":
url = self.server_url + "ajax/read.php"
else:
url = self.server_url + "/ajax/read.php"
request = requests.post(url,
data="",
headers=self.headers,
verify=os.path.join(os.path.dirname(os.path.realpath(__file__)),
Expand All @@ -59,7 +63,11 @@ def push(self, data):
:return: was the push successful?
:rtype: bool
"""
response = requests.post(self.server_url + "ajax/write.php",
if self.server_url[-1] == "/":
url = self.server_url + "ajax/write.php"
else:
url = self.server_url + "/ajax/write.php"
response = requests.post(url,
data={'data': data},
headers=self.headers,
verify=os.path.join(os.path.dirname(os.path.realpath(__file__)),
Expand Down

0 comments on commit e4af10b

Please sign in to comment.