submit right form, remove debugging

This commit is contained in:
Neale Pickett 2020-03-10 14:28:50 -06:00
parent 04136ef264
commit a963daa19a
2 changed files with 3 additions and 8 deletions

View File

@ -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()

View File

@ -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) {