Added static web server and black / whitelist template

- Added static web server
- Added static web server default index
- Added embeded templates to blacklist / whitelist
- Added wip Web Directory Manager

Place the templates at ./www/templates/blacklist.html or whitelist.html to replace the build in embedded template for access control 403 error
-
This commit is contained in:
Toby Chui
2023-09-14 16:15:40 +08:00
parent ed92cccf0e
commit b63a0fc246
34 changed files with 6991 additions and 26 deletions

View File

@@ -5,6 +5,7 @@ import (
"log"
"net/http"
"os"
"strconv"
"strings"
"time"
)
@@ -76,6 +77,22 @@ func PostBool(r *http.Request, key string) (bool, error) {
return false, errors.New("invalid boolean given")
}
// Get POST paramter as int
func PostInt(r *http.Request, key string) (int, error) {
x, err := PostPara(r, key)
if err != nil {
return 0, err
}
x = strings.TrimSpace(x)
rx, err := strconv.Atoi(x)
if err != nil {
return 0, err
}
return rx, nil
}
func FileExists(filename string) bool {
_, err := os.Stat(filename)
if os.IsNotExist(err) {