Skip to content

Instantly share code, notes, and snippets.

@gidutz
Created November 17, 2019 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gidutz/6c29981bbaa9099980c0cfb69c2273e5 to your computer and use it in GitHub Desktop.
Save gidutz/6c29981bbaa9099980c0cfb69c2273e5 to your computer and use it in GitHub Desktop.
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