mirror of https://github.com/dirtbags/moth.git
submit right form, remove debugging
This commit is contained in:
parent
04136ef264
commit
a963daa19a
|
@ -77,12 +77,12 @@ class MothRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"data": {
|
"data": {
|
||||||
"short": "",
|
"short": "",
|
||||||
"description": "Provided answer was not in list of answers"
|
"description": "%r was not in list of answers" % self.req.get("answer")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.req.get("answer") in puzzle.answers:
|
if self.req.get("answer") in puzzle.answers:
|
||||||
ret["data"]["description"] = "Answer is correct"
|
ret["data"]["description"] = "Answer %r is correct" % self.req.get("answer")
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header("Content-Type", "application/json")
|
self.send_header("Content-Type", "application/json")
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
|
@ -71,21 +71,16 @@ async function possiblyCorrect(answer) {
|
||||||
// something like the github 404 page.
|
// something like the github 404 page.
|
||||||
for (let len = 0; len <= answer.length; len += 1) {
|
for (let len = 0; len <= answer.length; len += 1) {
|
||||||
if (window.puzzle.xAnchors.includes("end") && (len != answer.length)) {
|
if (window.puzzle.xAnchors.includes("end") && (len != answer.length)) {
|
||||||
console.log(` Skipping unanchored end (len=${len})`)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
console.log(" What about length", len)
|
|
||||||
for (let pos = 0; pos < answer.length - len + 1; pos += 1) {
|
for (let pos = 0; pos < answer.length - len + 1; pos += 1) {
|
||||||
if (window.puzzle.xAnchors.includes("begin") && (pos > 0)) {
|
if (window.puzzle.xAnchors.includes("begin") && (pos > 0)) {
|
||||||
console.log(` Skipping unanchored begin (pos=${pos})`)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
let sub = answer.substring(pos, pos+len)
|
let sub = answer.substring(pos, pos+len)
|
||||||
let digest = await sha256Hash(sub)
|
let digest = await sha256Hash(sub)
|
||||||
|
|
||||||
console.log(" Could it be", sub, digest)
|
|
||||||
if (digest == correctHash) {
|
if (digest == correctHash) {
|
||||||
console.log(" YESSS")
|
|
||||||
return sub
|
return sub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +115,7 @@ function submit(e) {
|
||||||
window.data = data
|
window.data = data
|
||||||
fetch("answer", {
|
fetch("answer", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: new FormData(e.target),
|
body: data,
|
||||||
})
|
})
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
|
|
Loading…
Reference in New Issue