Mercurial Hosting > d2o
comparison main.go @ 7:8e4813b4e509
update index style + justfile additions
| author | Atarwn Gard <a@qwa.su> |
|---|---|
| date | Tue, 10 Mar 2026 12:12:33 +0500 |
| parents | 07b6f06899e0 |
| children | 2ffb8028ccbb |
comparison
equal
deleted
inserted
replaced
| 6:54ab94198677 | 7:8e4813b4e509 |
|---|---|
| 272 if err != nil { | 272 if err != nil { |
| 273 http.Error(w, "cannot read directory", http.StatusInternalServerError) | 273 http.Error(w, "cannot read directory", http.StatusInternalServerError) |
| 274 return | 274 return |
| 275 } | 275 } |
| 276 w.Header().Set("Content-Type", "text/html; charset=utf-8") | 276 w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| 277 fmt.Fprintf(w, "<html><head><title>Index of %s</title></head><body>\n", urlPath) | 277 fmt.Fprintf(w, "<html><head><title>Index of %s</title><style>body{font-family:monospace}</style></head><body>\n", urlPath) |
| 278 fmt.Fprintf(w, "<h2>Index of %s</h2><hr><pre>\n", urlPath) | 278 fmt.Fprintf(w, "<h2>Index of %s</h2><pre>\n", urlPath) |
| 279 if urlPath != "/" { | 279 if urlPath != "/" { |
| 280 fmt.Fprintf(w, "<a href=\"..\">..</a>\n") | 280 fmt.Fprintf(w, "<a href=\"..\">..</a>\n") |
| 281 } | 281 } |
| 282 for _, e := range entries { | 282 for _, e := range entries { |
| 283 name := e.Name() | 283 name := e.Name() |
| 284 if e.IsDir() { | 284 if e.IsDir() { |
| 285 name += "/" | 285 name += "/" |
| 286 } | 286 } |
| 287 fmt.Fprintf(w, "<a href=\"%s\">%s</a>\n", path.Join(urlPath, name), name) | 287 fmt.Fprintf(w, "<a href=\"%s\">%s</a>\n", path.Join(urlPath, name), name) |
| 288 } | 288 } |
| 289 fmt.Fprintf(w, "</pre><hr><i>d2o webserver</i></body></html>") | 289 fmt.Fprintf(w, "</pre><i>d2o webserver</i></body></html>") |
| 290 } | 290 } |
| 291 | 291 |
| 292 // --- Reverse proxy ---------------------------------------------------------- | 292 // --- Reverse proxy ---------------------------------------------------------- |
| 293 | 293 |
| 294 func serveReverseProxy(w http.ResponseWriter, r *http.Request, target string) { | 294 func serveReverseProxy(w http.ResponseWriter, r *http.Request, target string) { |
