HTML templates

This commit is contained in:
DarkCat09 2023-10-13 14:44:47 +04:00
parent 7b06cbf939
commit 32a9853d1c
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3
4 changed files with 53 additions and 4 deletions

18
app.go
View file

@ -1,13 +1,25 @@
package main
import "github.com/gofiber/fiber/v2"
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html/v2"
)
func main() {
app := fiber.New()
app := fiber.New(fiber.Config{
Views: setupTemplates(),
})
app.Static("/public", "./public")
app.Get("/", func(ctx *fiber.Ctx) error {
return ctx.SendString("Privacy6")
return ctx.Render("index", fiber.Map{})
})
app.Listen("localhost:4200")
}
func setupTemplates() *html.Engine {
engine := html.New("./views", ".html")
return engine
}

7
go.mod
View file

@ -2,10 +2,15 @@ module dc09.ru/privacyhex
go 1.21.2
require github.com/gofiber/fiber/v2 v2.49.2
require (
github.com/gofiber/fiber/v2 v2.49.2
github.com/gofiber/template/html/v2 v2.0.5
)
require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/gofiber/template v1.8.2 // indirect
github.com/gofiber/utils v1.1.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect

6
go.sum
View file

@ -2,6 +2,12 @@ github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/gofiber/fiber/v2 v2.49.2 h1:ONEN3/Vc+dUCxxDgZZwpqvhISgHqb+bu+isBiEyKEQs=
github.com/gofiber/fiber/v2 v2.49.2/go.mod h1:gNsKnyrmfEWFpJxQAV0qvW6l70K1dZGno12oLtukcts=
github.com/gofiber/template v1.8.2 h1:PIv9s/7Uq6m+Fm2MDNd20pAFFKt5wWs7ZBd8iV9pWwk=
github.com/gofiber/template v1.8.2/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8=
github.com/gofiber/template/html/v2 v2.0.5 h1:BKLJ6Qr940NjntbGmpO3zVa4nFNGDCi/IfUiDB9OC20=
github.com/gofiber/template/html/v2 v2.0.5/go.mod h1:RCF14eLeQDCSUPp0IGc2wbSSDv6yt+V54XB/+Unz+LM=
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=

26
views/index.html Normal file
View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PrivacyHex</title>
</head>
<body>
<main>
<div class="logo">
<span class="logo-text">Privacy</span>
</div>
<form action="/goto" method="get">
<label>
<input type="text" name="q" placeholder="Search query or URL">
</label>
<label>
<input type="clear">
</label>
<label>
<input type="submit">
</label>
</form>
</main>
</body>
</html>