delete useless
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
28
main.go
28
main.go
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user