mirror of
https://github.com/nikdoof/website-hugo.git
synced 2025-12-13 12:12:18 +00:00
Add fcgi status script for retro
This commit is contained in:
@@ -5,11 +5,7 @@ layout: home
|
||||
hero_image: rose_logo.svg
|
||||
---
|
||||
|
||||
{{< rawhtml >}}
|
||||
<div class="notification has-text-centered" id="hackspace-open">
|
||||
Leigh Hackspace is currently <span id="hackspace-status"><i class="fas fa-spinner fa-spin"></i></span>
|
||||
</div>
|
||||
{{</ rawhtml >}}
|
||||
{{< openstatus >}}
|
||||
|
||||
| Day | Opening Times |
|
||||
| --------- | ------------- |
|
||||
|
||||
1
themes/lhs-retro/layouts/shortcodes/openstatus.html
Normal file
1
themes/lhs-retro/layouts/shortcodes/openstatus.html
Normal file
@@ -0,0 +1 @@
|
||||
<p>Leigh Hackspace is currently {{ "<!--# include virtual='/cgi/status.cgi' -->" | safeHTML }}</p>
|
||||
24
themes/lhs-retro/static/cgi/status.cgi
Normal file
24
themes/lhs-retro/static/cgi/status.cgi
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
# Get the current hackspace status from the SpaceAPI
|
||||
import requests
|
||||
import sys
|
||||
|
||||
|
||||
def main(output=sys.stdout):
|
||||
output.write('Content-Type: text/html\n\n')
|
||||
|
||||
try:
|
||||
resp = requests.get('https://api.leighhack.org/space.json')
|
||||
if resp.ok:
|
||||
data = resp.json()
|
||||
if 'state' in data:
|
||||
if data['state']['open']:
|
||||
output.write('<b>Open</b>')
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
output.write('Closed')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
3
themes/lhs/layouts/shortcodes/openstatus.html
Normal file
3
themes/lhs/layouts/shortcodes/openstatus.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="notification has-text-centered" id="hackspace-open">
|
||||
<p>Leigh Hackspace is currently <span id="hackspace-status"><i class="fas fa-spinner fa-spin"></i></span></p>
|
||||
</div>
|
||||
Reference in New Issue
Block a user