| | package http |
| |
|
| | import ( |
| | "io/fs" |
| | "net/http" |
| |
|
| | "github.com/labstack/echo/v4" |
| | "github.com/mudler/LocalAI/core/explorer" |
| | "github.com/mudler/LocalAI/core/http/middleware" |
| | "github.com/mudler/LocalAI/core/http/routes" |
| | "github.com/mudler/xlog" |
| | ) |
| |
|
| | func Explorer(db *explorer.Database) *echo.Echo { |
| | e := echo.New() |
| |
|
| | |
| | e.Renderer = renderEngine() |
| |
|
| | |
| | e.HideBanner = true |
| |
|
| | e.Pre(middleware.StripPathPrefix()) |
| | routes.RegisterExplorerRoutes(e, db) |
| |
|
| | |
| | e.GET("/favicon.svg", func(c echo.Context) error { |
| | data, err := embedDirStatic.ReadFile("static/favicon.svg") |
| | if err != nil { |
| | return c.NoContent(http.StatusNotFound) |
| | } |
| | c.Response().Header().Set("Content-Type", "image/svg+xml") |
| | return c.Blob(http.StatusOK, "image/svg+xml", data) |
| | }) |
| |
|
| | |
| | staticFS, err := fs.Sub(embedDirStatic, "static") |
| | if err != nil { |
| | |
| | xlog.Error("failed to create static filesystem", "error", err) |
| | } else { |
| | e.StaticFS("/static", staticFS) |
| | } |
| |
|
| | |
| | |
| | e.GET("/*", notFoundHandler) |
| |
|
| | return e |
| | } |
| |
|