blob: d6d74552cd70938d6411f03bf12ab9dc3c8d7c4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package main
import (
"log"
"net/http"
"strings"
"pablotron.org/jim-bot/bot"
)
// serve home page
func doHome(w http.ResponseWriter, _ *http.Request) {
// generate respones body
body := []byte(strings.Join(bot.N(10), "\n") + "\n")
// write header and response
w.Header().Add("Content-Type", "text/plain")
if _, err := w.Write(body); err != nil {
log.Print(err)
}
}
func main() {
http.HandleFunc("/", doHome)
http.ListenAndServe(":8080", nil)
}
|