Commit 0206cda0 authored by Christian Elberfeld's avatar Christian Elberfeld

Dummy-Implementierung für webseitenstatus

parent 509cc232
/warpapi/__pycache__
......@@ -11,18 +11,52 @@ app = Flask(__name__, static_url_path='')
if __name__ == "__main__":
app.run()
# Startseite
@app.route('/')
def hello_world():
return 'Warpzone API'
# Statische Dateien
@app.route('/static/<path:path>')
def send_static(path):
return send_from_directory('static', path)
# Statusanzeige auf der Webseite
@app.route('/status')
def staus():
spaceopen = 0
now = datetime.datetime.now(pytz.timezone('Europe/Berlin'))
dayofweek = now.strftime("%w")
# Hardcode Mittwoch Abend offen
if dayofweek == "3":
if now.hour >= 18:
spaceopen = 1
# Hardcode Samstag Abend offen
if dayofweek == "6":
if now.hour >= 18:
spaceopen = 1
data = {
"tuerOffen": spaceopen,
"tempLoungece": 25,
"tempWerkstatt": 25,
"timestamp": 0,
"age": 0
}
response = app.response_class(
response=json.dumps(data),
status=200,
mimetype='application/json'
)
return response
# Endpunkt für Einbindung in cpu.ccc.de
# Eigentlich die SpaceAPI, aber so können einfacher Abweichungen implementiert werden
@app.route('/cccapi')
def cccapi():
return redirect('/spaceapi', code=302)
# Implementierung der SpaceAPI
@app.route('/spaceapi')
def spaceapi():
spaceopen = False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment