cleaning up, early http server draft

This commit is contained in:
2026-01-24 09:39:27 +03:00
parent d52658ab5c
commit cc5c9c6d1a
23 changed files with 123 additions and 0 deletions

40
http/http.go Normal file
View File

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

4
http/index.html Normal file
View File

@@ -0,0 +1,4 @@
<form action="/upload" method="POST" enctype="multipart/form-data">
<input type="file" name="image" accept="image/*" required>
<button type="submit">Upload Image</button>
</form>