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",
|
||||
"data": {
|
||||
"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:
|
||||
ret["data"]["description"] = "Answer is correct"
|
||||
ret["data"]["description"] = "Answer %r is correct" % self.req.get("answer")
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.end_headers()
|
||||
|
|
|
@ -71,21 +71,16 @@ async function possiblyCorrect(answer) {
|
|||
// something like the github 404 page.
|
||||
for (let len = 0; len <= answer.length; len += 1) {
|
||||
if (window.puzzle.xAnchors.includes("end") && (len != answer.length)) {
|
||||
console.log(` Skipping unanchored end (len=${len})`)
|
||||
continue
|
||||
}
|
||||
console.log(" What about length", len)
|
||||
for (let pos = 0; pos < answer.length - len + 1; pos += 1) {
|
||||
if (window.puzzle.xAnchors.includes("begin") && (pos > 0)) {
|
||||
console.log(` Skipping unanchored begin (pos=${pos})`)
|
||||
continue
|
||||
}
|
||||
let sub = answer.substring(pos, pos+len)
|
||||
let digest = await sha256Hash(sub)
|
||||
|
||||
console.log(" Could it be", sub, digest)
|
||||
if (digest == correctHash) {
|
||||
console.log(" YESSS")
|
||||
return sub
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +115,7 @@ function submit(e) {
|
|||
window.data = data
|
||||
fetch("answer", {
|
||||
method: "POST",
|
||||
body: new FormData(e.target),
|
||||
body: data,
|
||||
})
|
||||
.then(resp => {
|
||||
if (resp.ok) {
|
||||
|
|
Loading…
Reference in New Issue