Created
December 24, 2016 11:20
-
-
Save Bigomby/d0879e5067537defdc5be19d813c6a57 to your computer and use it in GitHub Desktop.
Ejemplo básico de uso de la API de reserva de salas
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
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