This commit is contained in:
Neale Pickett 2023-01-06 09:32:16 -07:00
parent 45577f3ff3
commit 713f91a844
3 changed files with 22 additions and 5 deletions

View File

@ -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

View File

@ -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))
}

View File

@ -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;
}