gotracker/cmd/main.go

51 lines
877 B
Go
Raw Permalink Normal View History

2024-10-25 18:57:53 +02:00
package main
import (
"log/slog"
"os"
"screenshot/ocr"
// "github.com/kbinani/screenshot"
"github.com/gin-gonic/gin"
"github.com/otiai10/gosseract/v2"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
type Quest struct {
ID uint `gorm:"primaryKey"`
Name string
Value int
MaxValue int
}
func main() {
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
if err != nil {
logger.Error("Failed to connect to database:", err)
}
db.AutoMigrate(&Quest{})
r := gin.New()
r.Use(gin.Logger())
r.Use(gin.Recovery())
client := gosseract.NewClient()
defer client.Close()
r.POST("/", func(c *gin.Context) {
ocr.NewGetTextHandler(ocr.GetTextHandlerParams{
Logger: *logger,
Client: *client,
}).ServeHTTP(c, c.Writer, c.Request)
})
r.Run()
}