28 lines
517 B
Go
28 lines
517 B
Go
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))
|
||
}
|