update /check and setup html

This commit is contained in:
Jordan Blasenhauer 2024-03-12 11:12:10 +01:00
parent 671a0829fa
commit 122b64c2d4
2 changed files with 14 additions and 2 deletions

View file

@ -446,7 +446,7 @@ def check():
if "Origin" not in request.headers:
return Response(status=403)
return Response(status=200, headers={"Access-Control-Allow-Origin": "*"})
return Response(status=200, headers={"Access-Control-Allow-Origin": "*"}, response=dumps({"message": "ok"}), content_type="application/json")
@app.route("/setup", methods=["GET", "POST"])

View file

@ -348,7 +348,19 @@
}://${this.servInp.value}/setup/check`;
fetch(api)
.then((res) => {
this.updateCheck("success");
// check if status 200 and body = {"message" : "ok"}
if (res.status === 200) {
return res.json();
} else {
this.updateCheck("error");
}
}).then(res => {
// check message
if (res.message === "ok") {
this.updateCheck("success");
} else {
this.updateCheck("error");
}
})
.catch((err) => {
this.updateCheck("error");