delete useless

This commit is contained in:
M1n-0
2024-06-05 19:28:58 +02:00
parent 9179ec94b3
commit dbc1bbcd21
5 changed files with 0 additions and 93 deletions

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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
}

3
go.mod
View File

@@ -1,3 +0,0 @@
module hub
go 1.19

28
main.go
View File

@@ -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)
}
}