base server and base html
This commit is contained in:
34
assets/css/index.css
Normal file
34
assets/css/index.css
Normal file
@@ -0,0 +1,34 @@
|
||||
body {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.Mino{
|
||||
color: white;
|
||||
-webkit-animation: slide-in-left 0.9s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
||||
animation: slide-in-left 0.9s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
|
||||
|
||||
}
|
||||
@-webkit-keyframes slide-in-left {
|
||||
0% {
|
||||
-webkit-transform: translateX(-1000px);
|
||||
transform: translateX(-1000px);
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: translateX(0);
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes slide-in-left {
|
||||
0% {
|
||||
-webkit-transform: translateX(-1000px);
|
||||
transform: translateX(-1000px);
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: translateX(0);
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
0
assets/img/fakeimg.jpg
Normal file
0
assets/img/fakeimg.jpg
Normal file
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)
|
||||
}
|
||||
}
|
||||
26
controller/testpage.go
Normal file
26
controller/testpage.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
infini "infini/functions"
|
||||
"net/http"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
func TestPage(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if r.URL.Path != "/test" { // 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/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)
|
||||
}
|
||||
}
|
||||
10
functions/notfound.go
Normal file
10
functions/notfound.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package infini
|
||||
|
||||
import "net/http"
|
||||
|
||||
func NotFound(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
9
html/index.html
Normal file
9
html/index.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Test</title>
|
||||
<link rel="stylesheet" href="css/index.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1 class="Mino">Mino</h1>
|
||||
<a href="/test">test</a>
|
||||
</body>
|
||||
2
html/test.html
Normal file
2
html/test.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<a href="/">back</a> <br>
|
||||
UwU
|
||||
28
main.go
Normal file
28
main.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
controller "infini/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