-
Notifications
You must be signed in to change notification settings - Fork 0
/
egeus.go
53 lines (37 loc) · 932 Bytes
/
egeus.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"html/template"
"log"
"net/http"
"os"
"quintus"
)
func checkerror(err error) {
if err != nil {
log.Fatalln("[ERROR]", err)
}
}
func handle_index(w http.ResponseWriter, r *http.Request) {
t, err := template.ParseFiles("templates/layout.template", "templates/index.template")
checkerror(err)
t.Execute(w, someq)
}
var someq []quintus.Quintus
func init() {
qs := make([]quintus.Quintus, 1)
qs[0].Name = "Go"
qs[0].Date = "Today"
qs[0].Times = 0
quintus.Write(qs)
someq = quintus.Read()
log.Println("[INFO]", "LOADED GOB", someq)
}
func main() {
workingdirectory, err := os.Getwd()
checkerror(err)
log.Println("[INFO]", "Starting server in directory", workingdirectory)
http.HandleFunc("/", handle_index)
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir(workingdirectory+`/public`))))
err = http.ListenAndServe(":9090", nil)
checkerror(err)
}