Added basic healthcheck

This commit is contained in:
2025-05-22 16:23:29 +01:00
parent eca8fe6a4f
commit 216552bc2a

12
main.go
View File

@@ -18,6 +18,7 @@ const TEMPLATE_FILE = "main.py.tmpl"
func main() {
http.HandleFunc("/create_model", handleCreateModel)
http.HandleFunc("/health", handleHealthCheck)
port := os.Getenv("PORT")
if port == "" {
@@ -190,3 +191,14 @@ func create_glb(model_code string, filename string) (string, error) {
result := buf.String()
return result, nil
}
func handleHealthCheck(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("OK"))
}