stubbed out go handlers

This commit is contained in:
Stephen McQuay 2013-05-08 22:57:52 -07:00
parent aff09ed2a1
commit 60fc35e6c8
3 changed files with 19 additions and 4 deletions

13
handlers.go Normal file
View File

@ -0,0 +1,13 @@
package main
import (
"net/http"
)
func attempt(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("hello"))
}
func problem(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("hello"))
}

View File

@ -16,6 +16,8 @@ func main() {
flag.Parse() flag.Parse()
http.Handle("/", http.Handle("/",
http.FileServer(http.Dir(*static_files))) http.FileServer(http.Dir(*static_files)))
http.HandleFunc("/api/v0/attempt/", attempt)
http.HandleFunc("/api/v0/problem/", problem)
if err := http.ListenAndServe(*addr, nil); err != nil { if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err) log.Fatal("ListenAndServe:", err)
} }

View File

@ -1,9 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>{{ title }}</title> <title>Mardson's Math Game</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{% static "math.css" %}" rel="stylesheet" media="screen"> <link href="/math.css" rel="stylesheet" media="screen">
</head> </head>
<body> <body>
<section id="content"> <section id="content">
@ -17,7 +17,7 @@
<footer> <footer>
score: <span id="score"></span> score: <span id="score"></span>
</footer> </footer>
<script src="{% static 'jquery-2.0.0.min.js' %}"></script> <script src="/jquery-2.0.0.min.js"></script>
<script src="{% static "math.js" %}"></script> <script src="/math.js"></script>
</body> </body>
</html> </html>