-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (28 loc) · 806 Bytes
/
main.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
package main
import (
"fmt"
"github.com/joho/godotenv"
"log"
"net/http"
"github.com/Emmrys-Jay/my-photo-blog/controllers"
"github.com/Emmrys-Jay/my-photo-blog/models"
)
func init() {
_ = godotenv.Load("load.env")
}
func main() {
models.ConnectDB()
m := controllers.GetMuxVar()
mux := http.NewServeMux()
mux.Handle("/views/", http.StripPrefix("/views/", http.FileServer(http.Dir("views"))))
mux.HandleFunc("/", m.ReadPics)
mux.HandleFunc("/signin", m.Signin)
mux.HandleFunc("/signup", m.Signup)
mux.HandleFunc("/add", m.Addpic)
mux.HandleFunc("/logout", m.Signout)
mux.HandleFunc("/update", m.UpdatePic)
mux.HandleFunc("/delete", m.DeletePic)
mux.HandleFunc("/search", m.SearchPics)
fmt.Println("Server now listening on port: 8080")
log.Fatal(http.ListenAndServe(":8080", mux))
}