Files
counter/main.go
aovantsev 0dcb5d9b87
Some checks reported errors
continuous-integration/drone/push Build encountered an error
init
2025-10-02 22:30:16 +03:00

26 lines
490 B
Go

package main
import (
"log"
"net/http"
)
func helloHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
w.Write([]byte("Hello world"))
}
func main() {
http.HandleFunc("/", helloHandler)
port := ":8080"
log.Printf("Server starting on port %s", port)
log.Fatal(http.ListenAndServe(port, nil))
}