2018-07-20 12:13:52 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-10-31 06:14:33 +00:00
|
|
|
|
2018-09-06 12:47:32 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
2018-09-14 12:04:03 +00:00
|
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
2018-07-20 12:13:52 +00:00
|
|
|
)
|
|
|
|
|
2018-11-06 18:02:03 +00:00
|
|
|
// Start the REST API server using the configuration provided
|
2018-11-17 05:21:39 +00:00
|
|
|
func Start(conf photoprism.Config) {
|
2018-11-09 19:48:23 +00:00
|
|
|
if conf.GetServerMode() != "" {
|
|
|
|
gin.SetMode(conf.GetServerMode())
|
2018-11-09 20:11:52 +00:00
|
|
|
} else if conf.IsDebug() == false {
|
2018-09-13 09:34:56 +00:00
|
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
}
|
|
|
|
|
2018-09-13 05:05:13 +00:00
|
|
|
app := gin.Default()
|
2018-07-20 12:13:52 +00:00
|
|
|
|
2018-09-24 09:27:46 +00:00
|
|
|
// Set template directory
|
|
|
|
app.LoadHTMLGlob(conf.GetTemplatesPath() + "/*")
|
|
|
|
|
|
|
|
registerRoutes(app, conf)
|
2018-07-20 12:13:52 +00:00
|
|
|
|
2018-11-09 19:48:23 +00:00
|
|
|
app.Run(fmt.Sprintf("%s:%d", conf.GetServerIP(), conf.GetServerPort()))
|
2018-09-27 06:59:53 +00:00
|
|
|
}
|