11package main
22
33import (
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) {
2017func 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) {
2925func 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- }
0 commit comments