Skip to content

Commit

Permalink
不那么傻的主页
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieYu4994 committed Jan 29, 2021
1 parent 5af0c8e commit 278a820
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
31 changes: 31 additions & 0 deletions Web/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

<!DOCTYPE html>
<html style="height: 100%;">
<head>
<meta charset="utf-8"/>
<title>{{ .SiteName }}</title>
<meta name="viewport" content="width=device-width"/>
</head>

<body style="height: 100%;background-color: #eff5f9;">
<div style="height: 95%;width: 600px;background-color: #fefefa;margin: 0 auto;border: 5px dashed #f16d7a;border-radius: 10px;">
<div style="margin-top: 3%;margin-bottom: 10px;text-align: center;font-size: 36px;font-family: Georgia, Palatino;color: #666666;line-height: 125%;">
<em>{{ .SiteName }}</em>
</div>
<hr style="width: 30%;margin: 0 auto;height: 0;border: none;border-top: 2px solid #cbd0d4;"/>
<span style="font-size: 14px; font-family: Georgia, Palatino; color: #666666; line-height: 200%;">
<div style="margin-top: 10px;text-align: center;">
<em>Hello! Here is the Bing API from {{ .SiteName }}.</em>
</div>
<div style="width: 70%;margin: 0 auto;text-align: left;margin-top: 10px;">
<em>The URLs are following:</em>
<div style="margin: 0;background-color: #0000000f;padding: 5px;border-radius: 10px;">
<a href="/HDRES/">1920x1080 分辨率</a></br>
<a href="/UHDRES/">最高分辨率</a></br>
<a href="/RANDOM/">随机 1920x1080 分辨率</a>
</div>
</div>
</span>
</div>
</body>
</html>
4 changes: 4 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion config.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 6 additions & 4 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/rand"
"net/http"
"text/template"
"time"
)

Expand All @@ -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)
}
Empty file removed nohup.out
Empty file.

0 comments on commit 278a820

Please sign in to comment.