-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (32 loc) · 1.42 KB
/
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
35
36
37
38
39
40
41
42
43
package main
import (
"ViLoW/handler"
"ViLoW/model"
"log"
"net/http"
"text/template"
"github.com/gorilla/mux"
)
func main() {
handler.Templates = template.Must(template.ParseGlob("./web/*.html"))
//clearDBVideo()
//clearDBUser()
//feedDBwVideo()
log.Println("Running app...")
router := mux.NewRouter()
router.HandleFunc("/", handler.IndexPageHandler).Methods("GET")
router.HandleFunc("/sign", handler.SignHandler).Methods("POST")
router.HandleFunc("/login", handler.LoginHandler).Methods("POST")
router.HandleFunc("/login", handler.LoginPageHandler).Methods("GET")
router.HandleFunc("/upload", handler.UploadPageHandler).Methods("POST")
router.HandleFunc("/logout", handler.LogoutHandler).Methods("GET")
router.HandleFunc("/videos", model.PostVideo).Methods("POST")
router.HandleFunc("/internal", handler.InternalPageHandler)
router.HandleFunc("/upvote/{videoID}", handler.UpVoteHandler).Methods("POST")
router.HandleFunc("/downvote/{videoID}", handler.DownVoteHandler).Methods("POST")
router.PathPrefix("/assets/").Handler(http.StripPrefix("/assets", http.FileServer(http.Dir("./web"))))
router.PathPrefix("/data/").Handler(http.StripPrefix("/data/", http.FileServer(http.Dir("./app/data"))))
router.HandleFunc("/videos", model.GetVideo).Methods("GET")
router.HandleFunc("/{id}", handler.WatchPageHandler).Methods("POST")
log.Fatal(http.ListenAndServe(":8000", router))
}