-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (37 loc) · 1.27 KB
/
main.go
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
40
41
42
43
44
45
46
47
package main
import (
"embed"
"flag"
"fmt"
"net/http"
"github.com/asiffer/svgg/api"
)
const BANNER = "\033[33m" + `
███████╗██╗ ██╗ ██████╗ ██████╗
██╔════╝██║ ██║██╔════╝ ██╔════╝
███████╗██║ ██║██║ ███╗██║ ███╗
╚════██║╚██╗ ██╔╝██║ ██║██║ ██║
███████║ ╚████╔╝ ╚██████╔╝╚██████╔╝
╚══════╝ ╚═══╝ ╚═════╝ ╚═════╝
` + "\033[0m"
//go:embed static
var static embed.FS
// config
var (
host string = "127.0.0.1"
port uint = 4444
)
func main() {
flag.StringVar(&host, "host", "127.0.0.1", "Listening IP")
flag.UintVar(&port, "port", 4444, "Listing port")
flag.Parse()
addr := fmt.Sprintf("%s:%d", host, port)
fmt.Println(BANNER)
api.Info.Printf("Server starts. Service is available at http://%s\n", addr)
mux := http.NewServeMux()
mux.Handle(api.STATIC_URL, http.FileServer(http.FS(static)))
mux.HandleFunc("/", api.Handler)
if err := http.ListenAndServe(addr, mux); err != nil {
api.Error.Panic(err)
}
}