Smart and Autonomous parking.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
951 B

#Authors: Oulis Evangelos, Oulis Nikolaos, Drosos Katsibras
#===================================================================
#!/usr/bin/env python
import json
import requests
server_ip = "iot-smart-parking.herokuapp.com"
server_port = "443"
API_ENDPOINT = 'https://' + server_ip + ':' + server_port + '/'
try:
# ser = serial.Serial(
# port='/dev/ttyACM0',
# baudrate = 9600,
# parity=serial.PARITY_NONE,
# stopbits=serial.STOPBITS_ONE,
# bytesize=serial.EIGHTBITS,
# timeout=1
# )
c = requests.get(url=API_ENDPOINT, params = {})
doc = c.json()
parking = None
for park in doc:
if park['status'] == True:
parking = park #{"no": park['no'], "status": park['status']}
break
print ("Free parking is Number: " + str(parking['no']))
# ser.write("b'" + parking['no'] + "'")
# ser.flush()
except (NameError, TypeError) as e:
print ("No free parking")
except requests.exceptions.ConnectionError:
print("No Internet access")