31 lines
669 B
Go
31 lines
669 B
Go
package main
|
|
|
|
import (
|
|
"fitra-backend/application"
|
|
"fitra-backend/controllers"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func main() {
|
|
go application.StartCleanupRoutine()
|
|
|
|
r := gin.Default()
|
|
r.LoadHTMLGlob("views/*")
|
|
|
|
r.GET("/", controllers.HandleIndex)
|
|
r.POST("/upload", controllers.HandleFileUpload)
|
|
r.GET("/uploads/:fileID/:filename", controllers.HandleFileDownload)
|
|
r.GET("/health", func(c *gin.Context) { c.JSON(200, gin.H{"status": "ok"}) })
|
|
|
|
if port := os.Getenv("PORT"); port != "" {
|
|
fmt.Printf("FITRA Backend starting on port %s\n", port)
|
|
r.Run(":" + port)
|
|
} else {
|
|
fmt.Println("FITRA Backend starting on port 8080")
|
|
r.Run(":8080")
|
|
}
|
|
}
|