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-09-13 18:54:34 +00:00
|
|
|
func Start(conf *photoprism.Config) {
|
|
|
|
if conf.ServerMode != "" {
|
|
|
|
gin.SetMode(conf.ServerMode)
|
2018-09-17 16:40:57 +00:00
|
|
|
} else if conf.Debug == 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-09-13 18:54:34 +00:00
|
|
|
app.Run(fmt.Sprintf("%s:%d", conf.ServerIP, conf.ServerPort))
|
2018-09-27 06:59:53 +00:00
|
|
|
}
|