feat: add basic http server with hello world

This commit is contained in:
maotovisk 2026-02-21 20:16:28 -03:00
parent 4f19235d8e
commit 35ca4d49cc

28
cmd/dropr-server/main.go Normal file
View file

@ -0,0 +1,28 @@
package main
import (
"fmt"
"net/http"
)
func main() {
const PORT = ":8080"
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "text/plain")
_, err := fmt.Fprintf(w, "Hello, World!")
if err != nil {
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
}
})
fmt.Println("Listening on port " + PORT)
err := http.ListenAndServe(PORT, nil)
if err != nil {
panic(err)
}
}