-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (30 loc) · 753 Bytes
/
main.go
File metadata and controls
39 lines (30 loc) · 753 Bytes
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
package main
import (
// "fmt"
// "html/template"
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
"mypersonalwebsite/config"
)
func main() {
r := mux.NewRouter()
db, err := sqlx.Connect("sqlite3", "file:db/db.sqlite?_foreign_keys=on")
if err != nil {
log.Fatalln(err)
}
fs := http.FileServer(http.Dir("./static/"))
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fs))
templates := loadTemplates()
// t, err := template.ParseGlob("./templates/*.html")
// if err != nil {
// log.Fatal(err)
// }
// debug output t
// fmt.Println(t.DefinedTemplates())
loadRoutes(r, routes, db, templates)
port := config.Port
log.Fatal(http.ListenAndServe(":"+port, r))
}