mirror of
https://github.com/nikdoof/website-hugo.git
synced 2025-12-13 21:32:23 +00:00
Lint and improve status CGI script
This commit is contained in:
@@ -5,20 +5,21 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
def main(output=sys.stdout):
|
def main(output=sys.stdout):
|
||||||
output.write('Content-Type: text/html\n\n')
|
output.write("Content-Type: text/html\n\n")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = requests.get('https://api.leighhack.org/space.json')
|
resp = requests.get("https://api.leighhack.org/space.json", timeout=3)
|
||||||
if resp.ok:
|
if resp.ok:
|
||||||
data = resp.json()
|
data = resp.json()
|
||||||
if 'state' in data:
|
if "state" in data and data["state"]["open"]:
|
||||||
if data['state']['open']:
|
output.write("<b>Open</b>")
|
||||||
output.write('<b>Open</b>')
|
return
|
||||||
return
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
output.write('Closed')
|
# If we have a HTTP error, exception, then just assume we're closed.
|
||||||
|
output.write("Closed")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user