Compare commits

...

2 Commits

Author SHA1 Message Date
df1dfd8b0c change: status as json instead of string
Some checks failed
ci / docker (push) Failing after 4s
2024-11-14 22:02:00 +01:00
acf88ffa6e feat: downtime status information 2024-11-14 22:02:00 +01:00

View File

@@ -169,7 +169,7 @@ def webhooks():
db.session.commit() db.session.commit()
return ("", 204) return ("", 204)
@app.route('/downtime', methods=["DELETE","POST"]) @app.route('/downtime', methods=["GET", "DELETE","POST"])
def downtime(): def downtime():
# check static access token # # check static access token #
@@ -179,11 +179,19 @@ def downtime():
if flask.request.method == "DELETE": if flask.request.method == "DELETE":
app.config["DOWNTIME"] = datetime.datetime.now() app.config["DOWNTIME"] = datetime.datetime.now()
return ('Downtime successfully disabled', 200)
elif flask.request.method == "POST": elif flask.request.method == "POST":
minutes = int(flask.request.args.get("minutes") or 5) minutes = int(flask.request.args.get("minutes") or 5)
app.config["DOWNTIME"] = datetime.datetime.now() + datetime.timedelta(minutes=minutes) app.config["DOWNTIME"] = datetime.datetime.now() + datetime.timedelta(minutes=minutes)
return ('Downtime set to {}'.format(app.config["DOWNTIME"].isoformat(), 204))
return ('', 204) elif flask.request.method == "GET":
dt = app.config["DOWNTIME"]
if dt < datetime.datetime.now():
return flask.jsonify({"title" : "No Downtime set at the moment", "message" : ""})
else:
delta = int((dt - datetime.datetime.now()).total_seconds()/60)
return flask.jsonify({"title" : "Downtime set for {}m until {}".format(delta, dt.isoformat()),
"message" : ""})
@app.route('/settings', methods=["GET", "POST"]) @app.route('/settings', methods=["GET", "POST"])