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 #! /bin/sh
tag=git.woozle.org/neale/wallart-server
cd $(dirname $0)/.. 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" "bytes"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt"
"image/png" "image/png"
"log"
"net/http" "net/http"
"os" "os"
"path" "path"
@ -106,7 +106,15 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
return 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() { func main() {
@ -120,5 +128,5 @@ func main() {
http.Handle("/wallart.bin", http.FileServer(cacheDir)) http.Handle("/wallart.bin", http.FileServer(cacheDir))
http.Handle("/wallart.png", http.FileServer(cacheDir)) http.Handle("/wallart.png", http.FileServer(cacheDir))
http.Handle("/", http.FileServer(http.Dir(*web))) http.Handle("/", http.FileServer(http.Dir(*web)))
http.ListenAndServe(*listen, nil) http.ListenAndServe(*listen, logRequestHandler(http.DefaultServeMux))
} }

View File

@ -1,5 +1,7 @@
html { html {
font-family: sans-serif; font-family: sans-serif;
background-color: #333;
color: #ddd;
text-align: center; text-align: center;
} }
@ -8,3 +10,7 @@ img#wallart {
width: 320px; width: 320px;
image-rendering: pixelated; image-rendering: pixelated;
} }
a {
color: #ccf;
}