diff --git a/EduSync.exe b/EduSync.exe index c5e6f76..35d309a 100644 Binary files a/EduSync.exe and b/EduSync.exe differ diff --git a/auth.go b/authHandler.go similarity index 82% rename from auth.go rename to authHandler.go index 9586320..0bad972 100644 --- a/auth.go +++ b/authHandler.go @@ -47,16 +47,7 @@ func AuthHandler(router *mux.Router, config *Config) { }).Methods("GET") router.HandleFunc("/login", func(res http.ResponseWriter, req *http.Request) { - t, err := template.ParseFiles("templates/index.html") - if err != nil { - http.Error(res, err.Error(), http.StatusInternalServerError) - return - } - t.Execute(res, false) - }).Methods("GET") - - router.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) { - t, err := template.ParseFiles("templates/home.html") + t, err := template.ParseFiles("templates/login.html") if err != nil { http.Error(res, err.Error(), http.StatusInternalServerError) return diff --git a/main.go b/main.go index 7fa92be..af2183f 100644 --- a/main.go +++ b/main.go @@ -19,12 +19,14 @@ func main() { } router := mux.NewRouter() + + // Serving static files fs := http.FileServer(http.Dir("assets")) router.PathPrefix("/assets").Handler(http.StripPrefix("/assets", fs)) - //http.Handle("/resources/", http.StripPrefix("/resources", fs)) // Set up authentication routes AuthHandler(router, config) + RoleHandler(router) log.Println("listening on localhost:8080") err = http.ListenAndServeTLS(":8080", "cert.pem", "key.pem", router) diff --git a/roleHandler.go b/roleHandler.go new file mode 100644 index 0000000..65c4902 --- /dev/null +++ b/roleHandler.go @@ -0,0 +1,46 @@ +package main + +import ( + "html/template" + "net/http" + + "github.com/gorilla/mux" +) + +func RoleHandler(router *mux.Router) { + router.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) { + t, err := template.ParseFiles("templates/index.html") + if err != nil { + http.Error(res, err.Error(), http.StatusInternalServerError) + return + } + t.Execute(res, false) + }).Methods("GET") + + router.HandleFunc("/admin", func(res http.ResponseWriter, req *http.Request) { + t, err := template.ParseFiles("templates/admin/index.html") + if err != nil { + http.Error(res, err.Error(), http.StatusInternalServerError) + return + } + t.Execute(res, nil) + }).Methods("GET") + + router.HandleFunc("/student", func(res http.ResponseWriter, req *http.Request) { + t, err := template.ParseFiles("templates/student/index.html") + if err != nil { + http.Error(res, err.Error(), http.StatusInternalServerError) + return + } + t.Execute(res, nil) + }).Methods("GET") + + router.HandleFunc("/instructor", func(res http.ResponseWriter, req *http.Request) { + t, err := template.ParseFiles("templates/instructor/index.html") + if err != nil { + http.Error(res, err.Error(), http.StatusInternalServerError) + return + } + t.Execute(res, nil) + }).Methods("GET") +} diff --git a/templates/admin/index.html b/templates/admin/index.html new file mode 100644 index 0000000..88a59fc --- /dev/null +++ b/templates/admin/index.html @@ -0,0 +1,170 @@ + + +
+Need assistance? Contact us at nkedusync@gmail.com
+Any Queries? Ask us a question at nkedusync@gmail.com
+