Files
server/main.go
Konstantin Grachev 4e06ababf3
All checks were successful
Build and Push / build-and-push (push) Successful in 1m5s
init
2025-07-18 22:20:49 +03:00

28 lines
517 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"embed"
"io/fs"
"log"
"net/http"
)
//go:embed public/*
var publicFS embed.FS
func main() {
// Получаем подпапку 'public' из embed.FS
pub, err := fs.Sub(publicFS, "public")
if err != nil {
log.Fatal(err)
}
// Создаем файловый сервер с корнем в подпапке public
fileServer := http.FileServer(http.FS(pub))
http.Handle("/", fileServer)
log.Println("Server starting on :8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}