diff --git a/controller/mainpage.go b/controller/mainpage.go deleted file mode 100644 index 9ebf4ec..0000000 --- a/controller/mainpage.go +++ /dev/null @@ -1,26 +0,0 @@ -package controller - -import ( - hub "hub/functions" - "net/http" - "text/template" -) - -func MainPage(w http.ResponseWriter, r *http.Request) { - - if r.URL.Path != "/" { // met l'url de la page - hub.NotFound(w, r) // si l'url n'est pas bonne, renvoie sur la page d'erreur 404 - return - } - - tmpl, err := template.ParseFiles("html/index.html") - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - err = tmpl.Execute(w, nil) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - } -} diff --git a/controller/testpage.go b/controller/testpage.go deleted file mode 100644 index dd4315f..0000000 --- a/controller/testpage.go +++ /dev/null @@ -1,26 +0,0 @@ -package controller - -import ( - hub "hub/functions" - "net/http" - "text/template" -) - -func TestPage(w http.ResponseWriter, r *http.Request) { - - if r.URL.Path != "/test" { // met l'url de la page - hub.NotFound(w, r) // si l'url n'est pas bonne, renvoie sur la page d'erreur 404 - return - } - - tmpl, err := template.ParseFiles("html/test.html") - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - err = tmpl.Execute(w, nil) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - } -} diff --git a/functions/notfound.go b/functions/notfound.go deleted file mode 100644 index 44b5649..0000000 --- a/functions/notfound.go +++ /dev/null @@ -1,10 +0,0 @@ -package Hub - -import "net/http" - -func NotFound(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusNotFound) - - http.Redirect(w, r, "/", http.StatusSeeOther) - return -} diff --git a/go.mod b/go.mod deleted file mode 100644 index e33041d..0000000 --- a/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module hub - -go 1.19 diff --git a/main.go b/main.go deleted file mode 100644 index c2bb392..0000000 --- a/main.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - controller "hub/controller" - "net/http" -) - -func main() { - - fs := http.FileServer(http.Dir("assets/")) - http.Handle("/assets/", http.StripPrefix("/assets/", fs)) - - http.HandleFunc("/", controller.MainPage) - http.HandleFunc("/test", controller.TestPage) - - // Print a message when the server is online - go func() { - fmt.Print("\n") - fmt.Println("Server is running on http://86.204.149.189:80") - fmt.Print("\n") - }() - - err := http.ListenAndServe("0.0.0.0:8080", nil) - if err != nil { - fmt.Println("Erreur lors du démarrage du serveur:", err) - } -}