Add space API

This commit is contained in:
redfast00 2019-12-27 20:56:42 +01:00
parent ab6e6ba816
commit 014558ccf0
No known key found for this signature in database
GPG Key ID: 5946E0E34FD0553C
1 changed files with 35 additions and 0 deletions

View File

@ -140,6 +140,41 @@ def door(username):
command = tokens[0].lower()
return mattermost_response(slotmachien_request(username, command), ephemeral=True)
@app.route('/spaceapi.json')
def spaceapi():
cammiestatus = requests.get('https://kelder.zeus.ugent.be/webcam/cgi/ptdc.cgi')
# Avoid XML parsing
status = '<lightADC>0</lightADC>' not in cammiestatus.text
response = jsonify({
"api": "0.13",
"space": "Zeus WPI",
"logo": "https://zinc.zeus.gent",
"url": "https://zeus.ugent.be",
"location": {
"address": "Zeuskelder, gebouw S9, Krijgslaan 281, Ghent, Belgium",
"lon": 3.7102741,
"lat": 51.0231119,
},
"contact": {
"email": "bestuur@zeus.ugent.be",
"twitter": "@ZeusWPI"
},
"issue_report_channels": ["email"],
"state": {
"icon": {
"open": "https://zinc.zeus.gent/zeus",
"closed": "https://zinc.zeus.gent/black"
},
"open": cammiestatus
},
"projects": [
"https://github.com/zeuswpi",
"https://git.zeus.gent"
]
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/doorkeeper', methods=['POST'])
@requires_token('doorkeeper')
def doorkeeper():