From cc5c9c6d1a4e6ec774b72fcdafc56e6350844456 Mon Sep 17 00:00:00 2001 From: potassium Date: Sat, 24 Jan 2026 09:39:27 +0300 Subject: [PATCH] cleaning up, early http server draft --- http/http.go | 40 ++++++++++++++++++ http/index.html | 4 ++ {cmd => pkg}/downscale/downscale.go | 0 {cmd => pkg}/downscale/main.go | 0 {cmd => pkg}/mesh/8.clock.png | Bin {cmd => pkg}/mesh/9p.go | 0 {cmd => pkg}/mesh/mesh.go | 0 {cmd => pkg}/mkpalette/palette.go | 0 {cmd => pkg}/negate/8.absolutecinema.png | Bin {cmd => pkg}/negate/minus19blue | Bin {cmd => pkg}/negate/minus19blue.go | 0 {cmd => pkg}/negate/mixed.go | 0 {cmd => pkg}/negate/negate | Bin {cmd => pkg}/negate/negate.go | 0 {cmd => pkg}/negate/negated5.png | Bin {cmd => pkg}/negate/negated8.png | Bin {cmd => pkg}/negate/reshaded,negated8.png | Bin {cmd => pkg}/showpalette/.show.go.swp | Bin {cmd => pkg}/showpalette/show.go | 0 util/.hex_test.go.swp | Bin 0 -> 12288 bytes util/hex.go | 32 +++++++++++++++ util/hex_test.go | 47 ++++++++++++++++++++++ util.go => util/util.go | 0 23 files changed, 123 insertions(+) create mode 100644 http/http.go create mode 100644 http/index.html rename {cmd => pkg}/downscale/downscale.go (100%) rename {cmd => pkg}/downscale/main.go (100%) rename {cmd => pkg}/mesh/8.clock.png (100%) rename {cmd => pkg}/mesh/9p.go (100%) rename {cmd => pkg}/mesh/mesh.go (100%) rename {cmd => pkg}/mkpalette/palette.go (100%) rename {cmd => pkg}/negate/8.absolutecinema.png (100%) rename {cmd => pkg}/negate/minus19blue (100%) rename {cmd => pkg}/negate/minus19blue.go (100%) rename {cmd => pkg}/negate/mixed.go (100%) rename {cmd => pkg}/negate/negate (100%) rename {cmd => pkg}/negate/negate.go (100%) rename {cmd => pkg}/negate/negated5.png (100%) rename {cmd => pkg}/negate/negated8.png (100%) rename {cmd => pkg}/negate/reshaded,negated8.png (100%) rename {cmd => pkg}/showpalette/.show.go.swp (100%) rename {cmd => pkg}/showpalette/show.go (100%) create mode 100644 util/.hex_test.go.swp create mode 100644 util/hex.go create mode 100644 util/hex_test.go rename util.go => util/util.go (100%) diff --git a/http/http.go b/http/http.go new file mode 100644 index 0000000..8361f67 --- /dev/null +++ b/http/http.go @@ -0,0 +1,40 @@ +package main + +import ( + "net/http" + "log" +) + +type imageTransform struct { + image.Image + TransformFunc func(image.Image) image.Image +} + +func (t imageTransform) ServeHTTP(w http.ResponseWriter, r *http.Request) { + +} + +func indexHTML(w http.ResponseWriter, r *http.Request) { + f, err := os.Open("index.html") + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + log.Fatalln("error opening file:", err) + return + } + _, err := io.Copy(w, f) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + log.Println("copy error:", err) + return + } +} + +func main() { + http.HandleFunc("/", indexHTML) + http.Handle("POST /upload", imageTransform) + + err := http.ListenAndServe(":8080", nil) + if err != nil { + log.Panicln(err) + } +} diff --git a/http/index.html b/http/index.html new file mode 100644 index 0000000..1dd1ca9 --- /dev/null +++ b/http/index.html @@ -0,0 +1,4 @@ +
+ + +
diff --git a/cmd/downscale/downscale.go b/pkg/downscale/downscale.go similarity index 100% rename from cmd/downscale/downscale.go rename to pkg/downscale/downscale.go diff --git a/cmd/downscale/main.go b/pkg/downscale/main.go similarity index 100% rename from cmd/downscale/main.go rename to pkg/downscale/main.go diff --git a/cmd/mesh/8.clock.png b/pkg/mesh/8.clock.png similarity index 100% rename from cmd/mesh/8.clock.png rename to pkg/mesh/8.clock.png diff --git a/cmd/mesh/9p.go b/pkg/mesh/9p.go similarity index 100% rename from cmd/mesh/9p.go rename to pkg/mesh/9p.go diff --git a/cmd/mesh/mesh.go b/pkg/mesh/mesh.go similarity index 100% rename from cmd/mesh/mesh.go rename to pkg/mesh/mesh.go diff --git a/cmd/mkpalette/palette.go b/pkg/mkpalette/palette.go similarity index 100% rename from cmd/mkpalette/palette.go rename to pkg/mkpalette/palette.go diff --git a/cmd/negate/8.absolutecinema.png b/pkg/negate/8.absolutecinema.png similarity index 100% rename from cmd/negate/8.absolutecinema.png rename to pkg/negate/8.absolutecinema.png diff --git a/cmd/negate/minus19blue b/pkg/negate/minus19blue similarity index 100% rename from cmd/negate/minus19blue rename to pkg/negate/minus19blue diff --git a/cmd/negate/minus19blue.go b/pkg/negate/minus19blue.go similarity index 100% rename from cmd/negate/minus19blue.go rename to pkg/negate/minus19blue.go diff --git a/cmd/negate/mixed.go b/pkg/negate/mixed.go similarity index 100% rename from cmd/negate/mixed.go rename to pkg/negate/mixed.go diff --git a/cmd/negate/negate b/pkg/negate/negate similarity index 100% rename from cmd/negate/negate rename to pkg/negate/negate diff --git a/cmd/negate/negate.go b/pkg/negate/negate.go similarity index 100% rename from cmd/negate/negate.go rename to pkg/negate/negate.go diff --git a/cmd/negate/negated5.png b/pkg/negate/negated5.png similarity index 100% rename from cmd/negate/negated5.png rename to pkg/negate/negated5.png diff --git a/cmd/negate/negated8.png b/pkg/negate/negated8.png similarity index 100% rename from cmd/negate/negated8.png rename to pkg/negate/negated8.png diff --git a/cmd/negate/reshaded,negated8.png b/pkg/negate/reshaded,negated8.png similarity index 100% rename from cmd/negate/reshaded,negated8.png rename to pkg/negate/reshaded,negated8.png diff --git a/cmd/showpalette/.show.go.swp b/pkg/showpalette/.show.go.swp similarity index 100% rename from cmd/showpalette/.show.go.swp rename to pkg/showpalette/.show.go.swp diff --git a/cmd/showpalette/show.go b/pkg/showpalette/show.go similarity index 100% rename from cmd/showpalette/show.go rename to pkg/showpalette/show.go diff --git a/util/.hex_test.go.swp b/util/.hex_test.go.swp new file mode 100644 index 0000000000000000000000000000000000000000..9f578a3b3e3091e7c4d8f62c722094b0b64274b3 GIT binary patch literal 12288 zcmYc?2=nw+u+%eTU|?VnU|>)%4#~)6c4oY##K2IHUy@i{oLQO+lEZ_OQd0|(^79Mu zC;>~=!41?eE=tzV%uP&BEiK8+Db_E@PS?*!t%xs4EiTbZ&j+g>B}PMFGz6#?0;MHs zx)!{l#zuw)ATyPf6cvPpLP5+?JQ@O{Aut*OqaiRF0;3@?8UmvsFd71*AuvKhprnA2 zp`L+(feGqgeJIU{Mnk!y)MyBdhQMeDjE2By2#kinXb6mkz-S1JhQMeDjE2By2#kin z5DbCD6b1$s9tMURJdpW+SpWYmKLf)Xeg=le{0t0t_!$_^^D{7<m!Oy_3mY;!P zH9rHxDt-or7JdeXV15P$HGT#L34R8KS9}Z%*Z3G1_VO_>Eazijn99e%Fp-aep_-3@ zA(D@Q!HtiB!Ge#0!Gw>2L7k6*L4}Wjft8Pe;V&-(!*5;&hF`o44A*!W7wtxm#h$yT3mwU?-B(q z(DLfcymY+~O@(R(hFS*BqSTVoqC5spkaukr(lT>WK^E$TC+1{>Ezwa(%Y!-;q7)P& z44mLFgKCC~aDp`FCFZ6o*eZa`VBq8g3xU{rt`#K^KP%YUDk$j{n=#OS=Vd{Dr+W#*)M z=B4H9FmRS77Ad6Vq59Gd6i~Jbpzs2_P@%Y_C^Iiz2NEQyMMWS}t0Ccu68unwnhF{q zSAjha)2gqpP@Y+mp#buyLTW`xYF=?>ex5>Ro_! zgTB5(5I7==!9k~xpQZq|OCdiwxwI%X1?*%722BP|C1?yPF>oq@LRKGSIfwxg$S($w r;8pedpde=8R7%S&QDVr