27 lines
538 B
Go
27 lines
538 B
Go
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)
|
|
}
|
|
}
|