base server and base html
This commit is contained in:
26
controller/mainpage.go
Normal file
26
controller/mainpage.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
infini "infini/functions"
|
||||
"net/http"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
func MainPage(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if r.URL.Path != "/" { // met l'url de la page
|
||||
infini.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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user