Skip to content

Commit b3f4cef

Browse files
committed
不实现主页功能
1 parent 00deb88 commit b3f4cef

5 files changed

Lines changed: 0 additions & 170 deletions

File tree

Web/404.html

Lines changed: 0 additions & 105 deletions
This file was deleted.

Web/template.html

Lines changed: 0 additions & 31 deletions
This file was deleted.

config.json.template

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"keypath": "/path/to/your/key/file",
55
"updatetime": "",
66
"port": "9090",
7-
"HTML": {
8-
"sitename": "LassiCat's APIs",
9-
"footer": ""
10-
}
117
}
128
//you can use relative path as well as absolute path
139
//if you set enabletls to false the pathes will be ignore

http.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package main
22

33
import (
4-
"fmt"
5-
"io/ioutil"
64
"math/rand"
75
"net/http"
8-
"text/template"
96
"time"
107
)
118

@@ -20,7 +17,6 @@ func redirectToHD(w http.ResponseWriter, r *http.Request) {
2017
func redirectToUHD(w http.ResponseWriter, r *http.Request) {
2118
if r.URL.Path != "/UHDRES/" {
2219
w.WriteHeader(http.StatusNotFound)
23-
pageNotFound(w)
2420
return
2521
}
2622
http.Redirect(w, r, picBuffer[0].UHDURL, 302)
@@ -29,34 +25,9 @@ func redirectToUHD(w http.ResponseWriter, r *http.Request) {
2925
func redirectToRANDOM(w http.ResponseWriter, r *http.Request) {
3026
if r.URL.Path != "/RANDOM/" {
3127
w.WriteHeader(http.StatusNotFound)
32-
pageNotFound(w)
3328
return
3429
}
3530
rand.Seed(time.Now().Unix())
3631
index := rand.Intn(len(picBuffer) - 1)
3732
http.Redirect(w, r, picBuffer[index].HDURL, 302)
3833
}
39-
40-
func homePage(w http.ResponseWriter, r *http.Request) {
41-
if r.URL.Path != "/" {
42-
w.WriteHeader(http.StatusNotFound)
43-
pageNotFound(w)
44-
return
45-
}
46-
tmpl, err := template.ParseFiles("./Web/template.html")
47-
if err != nil {
48-
w.WriteHeader(http.StatusInternalServerError)
49-
fmt.Fprintln(w, err)
50-
}
51-
tmpl.Execute(w, conf.HTML)
52-
}
53-
54-
func pageNotFound(w http.ResponseWriter) {
55-
content, err := ioutil.ReadFile("./Web/404.html")
56-
if err != nil {
57-
w.WriteHeader(http.StatusInternalServerError)
58-
fmt.Fprintln(w, err)
59-
return
60-
}
61-
fmt.Fprint(w, string(content))
62-
}

main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ func init() {
8181
}
8282

8383
func main() {
84-
http.HandleFunc("/", homePage)
8584
http.HandleFunc("/HDRES/", redirectToHD)
8685
http.HandleFunc("/UHDRES/", redirectToUHD)
8786
http.HandleFunc("/RANDOM/", redirectToRANDOM)

0 commit comments

Comments
 (0)