Skip to content

Instantly share code, notes, and snippets.

@Bigomby
Created December 24, 2016 11:20
Show Gist options
  • Save Bigomby/d0879e5067537defdc5be19d813c6a57 to your computer and use it in GitHub Desktop.
Save Bigomby/d0879e5067537defdc5be19d813c6a57 to your computer and use it in GitHub Desktop.
Ejemplo básico de uso de la API de reserva de salas
import requests
class colors:
OK = "\033[92m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
def print_turn(turn):
print(' ▶ [{}]:'.format(turn["time"]), end="")
if turn["available"]:
print("\t" + colors.OK + "Libre" + colors.ENDC)
else:
print("\t" + colors.FAIL + "Ocupada" + colors.ENDC)
def print_room(room):
sala = "SALA " + str(room)
print("-" * 31)
print(colors.BOLD + sala.center(31, " ") + colors.ENDC)
print("-" * 31)
response = requests.get("http://api.salas.gonebe.com/salas")
assert response.status_code == 200
for sala in response.json():
print_room(sala["id"])
for turn in sala["turns"]:
print_turn(turn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment