Commit 52b3a5ca authored by Simon Gölzhäuser's avatar Simon Gölzhäuser
Browse files

File upload & improvements

parent 02aa18d1
import http.client
import json
import time
identifier = input("Set device identifier: ")
if identifier == "":
print("Identifier empty")
print("-> Exit")
exit()
connection = http.client.HTTPSConnection("earth.informatik.uni-freiburg.de")
print("Requesting token")
while True:
connection.request("GET", ("/handwash/tokenauth/request/?identifier=" + identifier))
response = connection.getresponse()
if response.status != 200:
print("Request failed:")
print(response.status, response.reason)
print(response.headers)
print("-> Exit")
exit()
data = json.loads(response.read())
if data["status"] == "grant":
print("Access granted!")
print("Token: " + data["token"])
break
else:
print("...waiting for grant")
time.sleep(1)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment