added reset
This commit is contained in:
parent
e60f255522
commit
d1f1cfcd67
@ -135,3 +135,10 @@ func attempt(w http.ResponseWriter, req *http.Request) {
|
|||||||
log.Fatal("cannot marshal solution", err)
|
log.Fatal("cannot marshal solution", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reset(w http.ResponseWriter, req *http.Request) {
|
||||||
|
session, _ := store.Get(req, "Score")
|
||||||
|
session.Values["Score"] = 0
|
||||||
|
session.Save(req, w)
|
||||||
|
http.Redirect(w, req, "/", http.StatusFound)
|
||||||
|
}
|
||||||
|
4
main.go
4
main.go
@ -36,6 +36,10 @@ func main() {
|
|||||||
"/",
|
"/",
|
||||||
static,
|
static,
|
||||||
)
|
)
|
||||||
|
http.HandleFunc(
|
||||||
|
"/reset/",
|
||||||
|
reset,
|
||||||
|
)
|
||||||
if err := http.ListenAndServe(*addr, nil); err != nil {
|
if err := http.ListenAndServe(*addr, nil); err != nil {
|
||||||
log.Fatal("ListenAndServe:", err)
|
log.Fatal("ListenAndServe:", err)
|
||||||
}
|
}
|
||||||
|
63
static.go
63
static.go
@ -140,31 +140,48 @@ var staticIndexHtml = []byte{
|
|||||||
0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, // __conten
|
0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, // __conten
|
||||||
0x74, 0x22, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, // t_______
|
0x74, 0x22, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, // t_______
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
0x3c, 0x75, 0x6c, 0x3e, 0x0a, 0x20, 0x20, 0x20, // _ul_____
|
0x3c, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x20, 0x20, // _div____
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, // ______li
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x75, // _______u
|
||||||
0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, // __a_href
|
0x6c, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, // l_______
|
||||||
0x3d, 0x22, 0x2f, 0x61, 0x64, 0x64, 0x73, 0x75, // ___addsu
|
|
||||||
0x62, 0x2f, 0x22, 0x3e, 0x61, 0x64, 0x64, 0x69, // b___addi
|
|
||||||
0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x6e, 0x64, // tion_and
|
|
||||||
0x20, 0x73, 0x75, 0x62, 0x74, 0x72, 0x61, 0x63, // _subtrac
|
|
||||||
0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, 0x61, 0x3e, // tion__a_
|
|
||||||
0x3c, 0x2f, 0x6c, 0x69, 0x3e, 0x0a, 0x20, 0x20, // __li____
|
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, // _______l
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, // ________
|
||||||
0x69, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, // i__a_hre
|
0x6c, 0x69, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, // li__a_hr
|
||||||
0x66, 0x3d, 0x22, 0x2f, 0x6d, 0x75, 0x6c, 0x2f, // f___mul_
|
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x61, 0x64, 0x64, // ef___add
|
||||||
0x22, 0x3e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, // __multip
|
0x73, 0x75, 0x62, 0x2f, 0x22, 0x3e, 0x61, 0x64, // sub___ad
|
||||||
0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, // lication
|
0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, // dition_a
|
||||||
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x6c, 0x69, // __a___li
|
0x6e, 0x64, 0x20, 0x73, 0x75, 0x62, 0x74, 0x72, // nd_subtr
|
||||||
0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, // action__
|
||||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, // ________
|
0x61, 0x3e, 0x3c, 0x2f, 0x6c, 0x69, 0x3e, 0x0a, // a___li__
|
||||||
0x75, 0x6c, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, // ul______
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x73, 0x65, // ______se
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0a, 0x20, // ction___
|
0x20, 0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x3e, // _____li_
|
||||||
0x20, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, // _____bod
|
0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, // _a_href_
|
||||||
0x79, 0x3e, 0x0a, 0x3c, 0x2f, 0x68, 0x74, 0x6d, // y____htm
|
0x22, 0x2f, 0x6d, 0x75, 0x6c, 0x2f, 0x22, 0x3e, // __mul___
|
||||||
0x6c, 0x3e, 0x0a, // l____htm
|
0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x69, // multipli
|
||||||
|
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3c, 0x2f, // cation__
|
||||||
|
0x61, 0x3e, 0x3c, 0x2f, 0x6c, 0x69, 0x3e, 0x0a, // a___li__
|
||||||
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
|
0x3c, 0x2f, 0x75, 0x6c, 0x3e, 0x0a, 0x20, 0x20, // __ul____
|
||||||
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
|
0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, // ____div_
|
||||||
|
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x64, 0x69, // ______di
|
||||||
|
0x76, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, // v_______
|
||||||
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
|
0x20, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, // ____a_hr
|
||||||
|
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x72, 0x65, 0x73, // ef___res
|
||||||
|
0x65, 0x74, 0x2f, 0x22, 0x3e, 0x72, 0x65, 0x73, // et___res
|
||||||
|
0x65, 0x74, 0x20, 0x73, 0x63, 0x6f, 0x72, 0x65, // et_score
|
||||||
|
0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x0a, 0x20, 0x20, // s__a____
|
||||||
|
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
|
0x20, 0x20, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, // ____div_
|
||||||
|
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, // ________
|
||||||
|
0x20, 0x3c, 0x2f, 0x73, 0x65, 0x63, 0x74, 0x69, // ___secti
|
||||||
|
0x6f, 0x6e, 0x3e, 0x0a, 0x20, 0x20, 0x20, 0x20, // on______
|
||||||
|
0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0a, // __body__
|
||||||
|
0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0a, // __html__
|
||||||
}
|
}
|
||||||
|
|
||||||
var staticJqueryJs = []byte{
|
var staticJqueryJs = []byte{
|
||||||
|
@ -7,10 +7,15 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<section id="content">
|
<section id="content">
|
||||||
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/addsub/">addition and subtraction</a></li>
|
<li><a href="/addsub/">addition and subtraction</a></li>
|
||||||
<li><a href="/mul/">multiplication</a></li>
|
<li><a href="/mul/">multiplication</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="/reset/">reset scores</a>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user