Created
November 17, 2019 06:49
-
-
Save gidutz/6c29981bbaa9099980c0cfb69c2273e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_headers(self): | |
headers = { | |
'authority': self.host, | |
'x-requested-with': 'XMLHttpRequest', | |
'origin': 'https://{}'.format(self.host), | |
'x-csrf-token': self.x_csrf_token, | |
'user-agent': '...', | |
'content-type': 'application/json;charset=UTF-8', | |
'accept': '*/*', | |
'sec-fetch-site': 'same-origin', | |
'sec-fetch-mode': 'cors', | |
'referer': 'https://{}/home'.format(self.host), | |
'accept-encoding': 'gzip, deflate, br', | |
'accept-language': 'en-US,en;q=0.9,he;q=0.8', | |
'cookie': self.cookie, | |
} | |
return headers | |
def move(self, angle, throttle): | |
url = "https://" + self.host + '/api/manual_drive' | |
data = json.dumps({"angle": angle, "throttle": throttle}) | |
headers = self.get_headers() | |
response = requests.put(url, headers=headers, data=data, verify=False) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment