From c98669436742f79f8ffaa796ff94ee2c7f17201a Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 21 Sep 2023 16:35:38 -0700 Subject: [PATCH 1/2] fix HEAD / request HEAD request should respond like their GET counterparts except without a response body. --- server/routes.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/routes.go b/server/routes.go index c00bad65..f86ffd07 100644 --- a/server/routes.go +++ b/server/routes.go @@ -543,12 +543,11 @@ func Serve(ln net.Listener, allowOrigins []string) error { }, ) - r.GET("/", func(c *gin.Context) { - c.String(http.StatusOK, "Ollama is running") - }) - r.HEAD("/", func(c *gin.Context) { - c.Status(http.StatusOK) - }) + for _, method := range []string{http.MethodGet, http.MethodHead} { + r.Handle(method, "/", func(c *gin.Context) { + c.String(http.StatusOK, "Ollama is running") + }) + } r.POST("/api/pull", PullModelHandler) r.POST("/api/generate", GenerateHandler) From 82f5b66c01b11d706c1797ab676054d309724c6e Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 21 Sep 2023 16:38:03 -0700 Subject: [PATCH 2/2] register HEAD /api/tags --- server/routes.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/routes.go b/server/routes.go index f86ffd07..756efe30 100644 --- a/server/routes.go +++ b/server/routes.go @@ -543,22 +543,23 @@ func Serve(ln net.Listener, allowOrigins []string) error { }, ) - for _, method := range []string{http.MethodGet, http.MethodHead} { - r.Handle(method, "/", func(c *gin.Context) { - c.String(http.StatusOK, "Ollama is running") - }) - } - r.POST("/api/pull", PullModelHandler) r.POST("/api/generate", GenerateHandler) r.POST("/api/embeddings", EmbeddingHandler) r.POST("/api/create", CreateModelHandler) r.POST("/api/push", PushModelHandler) r.POST("/api/copy", CopyModelHandler) - r.GET("/api/tags", ListModelsHandler) r.DELETE("/api/delete", DeleteModelHandler) r.POST("/api/show", ShowModelHandler) + for _, method := range []string{http.MethodGet, http.MethodHead} { + r.Handle(method, "/", func(c *gin.Context) { + c.String(http.StatusOK, "Ollama is running") + }) + + r.Handle(method, "/api/tags", ListModelsHandler) + } + log.Printf("Listening on %s", ln.Addr()) s := &http.Server{ Handler: r,