diff --git a/Web/template.html b/Web/template.html new file mode 100644 index 0000000..65f7ca1 --- /dev/null +++ b/Web/template.html @@ -0,0 +1,31 @@ + + + + + +{{ .SiteName }} + + + + +
+
+ {{ .SiteName }} +
+
+ +
+ Hello! Here is the Bing API from {{ .SiteName }}. +
+
+ The URLs are following: +
+ 1920x1080 分辨率
+ 最高分辨率
+ 随机 1920x1080 分辨率 +
+
+
+
+ + \ No newline at end of file diff --git a/config.go b/config.go index 17af4dd..328b5eb 100644 --- a/config.go +++ b/config.go @@ -14,6 +14,10 @@ type config struct { KeyPath string `json:"keypath"` Port string `json:"port"` UpdateTime int `json:"updatetime"` + HTML struct { + SiteName string `json:"sitename"` + Footer string `json:"footer"` + } } func readConf(path string, conf *config) error { diff --git a/config.json.template b/config.json.template index eb7b2ee..6169fe7 100644 --- a/config.json.template +++ b/config.json.template @@ -3,7 +3,11 @@ "certpath": "/path/to/your/crt/file", "keypath": "/path/to/your/key/file", "updatetime": "", - "port": "9090" + "port": "9090", + "HTML": { + "sitename": "LassiCat's APIs", + "footer": "" + } } //you can use relative path as well as absolute path //if you set enabletls to false the pathes will be ignore \ No newline at end of file diff --git a/http.go b/http.go index d49845b..490e1ea 100644 --- a/http.go +++ b/http.go @@ -4,6 +4,7 @@ import ( "fmt" "math/rand" "net/http" + "text/template" "time" ) @@ -22,8 +23,9 @@ func redirectToRANDOM(w http.ResponseWriter, r *http.Request) { } func homePage(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, - `Here is LassiCat's BingAPI. -1920x1080: https://api.lassi-cat.cn:60443/HDRES -UHD : https://api.lassi-cat.cn:60443/UHDRES`) + tmpl, err := template.ParseFiles("./Web/template.html") + if err != nil { + fmt.Fprintln(w, err) + } + tmpl.Execute(w, conf.HTML) } diff --git a/nohup.out b/nohup.out deleted file mode 100644 index e69de29..0000000