-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpodserver.go
More file actions
39 lines (31 loc) · 804 Bytes
/
podserver.go
File metadata and controls
39 lines (31 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright ©2022-2025 Mr MXF info@mrmxf.com
// BSD-3-Clause License https://opensource.org/license/bsd-3-clause/
package main
// package main is a simple static web server that serves a hugo site.
//
import (
"fmt"
"log/slog"
"net/http"
"os"
"github.com/mrmxf/clog/gommi"
"github.com/mrmxf/clog/slogger"
)
// the default port to serve data is 8080
var Port = "8080"
var urlPrefix = "/"
var mountPath = "public"
func main() {
r, _ := gommi.Bare()
r.NewFileServer(urlPrefix, mountPath)
// run the server in a thread
slog.Info(fmt.Sprintf("Listening on port %s", Port))
http.ListenAndServe("0.0.0.0:"+Port, r)
}
func init() {
slogger.UsePrettyLogger(slog.LevelError)
containerDataPath, insideKo := os.LookupEnv("KO_DATA_PATH")
if insideKo {
mountPath = containerDataPath
}
}