-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonNN.go
48 lines (41 loc) · 1008 Bytes
/
onNN.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
package main
import (
"net/http"
"fmt"
"log"
"os"
"path/filepath"
"time"
"github.com/onNN/routes"
"github.com/onNN/models"
)
// routes
func handleRequests(env *routes.Env) {
// this is just for when browser requests favicon
http.HandleFunc("/favicon.ico", routes.HandlerICon)
http.HandleFunc("/neurons", env.AddNeuron)
http.HandleFunc("/build", env.Build)
http.HandleFunc("/test", routes.TestTemplate)
http.HandleFunc("/css/", routes.ServeResource)
log.Fatal(http.ListenAndServe(":3334", nil))
}
// log
func mutter(s string) {
fmt.Print(time.Now().Format(time.RFC850))
fmt.Print(" - ")
fmt.Println(s)
}
// main
func main() {
//Create a new DB Handle TODO: Support more that one DB
db, err := models.NewDB("MGO_DIAL")
if err != nil {
panic(err)
}
/* Can create Env with a DB obj, since DB class implements The Interface methods */
env := &routes.Env{db}
cwd, _ := os.Getwd()
fmt.Println(filepath.Join(cwd, "./templates/todos.html"))
handleRequests(env)
defer db.Close()
}