Logging
This commit is contained in:
parent
45577f3ff3
commit
713f91a844
|
@ -1,4 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
tag=git.woozle.org/neale/wallart-server
|
||||
|
||||
cd $(dirname $0)/..
|
||||
docker build -t wallart-server -f build/Dockerfile .
|
||||
docker build -t $tag -f build/Dockerfile .
|
||||
docker push $tag
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"image/png"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -106,7 +106,15 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
fmt.Fprintln(w, "It worked")
|
||||
log.Println("New image successfully uploaded")
|
||||
}
|
||||
|
||||
func logRequestHandler(h http.Handler) http.Handler {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL)
|
||||
h.ServeHTTP(w, r)
|
||||
}
|
||||
return http.HandlerFunc(fn)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -120,5 +128,5 @@ func main() {
|
|||
http.Handle("/wallart.bin", http.FileServer(cacheDir))
|
||||
http.Handle("/wallart.png", http.FileServer(cacheDir))
|
||||
http.Handle("/", http.FileServer(http.Dir(*web)))
|
||||
http.ListenAndServe(*listen, nil)
|
||||
http.ListenAndServe(*listen, logRequestHandler(http.DefaultServeMux))
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
html {
|
||||
font-family: sans-serif;
|
||||
background-color: #333;
|
||||
color: #ddd;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
@ -7,4 +9,8 @@ img#wallart {
|
|||
max-width: 90vw;
|
||||
width: 320px;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
color: #ccf;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue