-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.go
55 lines (49 loc) · 979 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"edulx/hax_woiden_vc_xqtx/api"
"edulx/hax_woiden_vc_xqtx/service"
"embed"
_ "embed"
"fmt"
"github.com/gin-gonic/gin"
"html/template"
"os"
)
//go:embed template/*
var f embed.FS
func main() {
if err := service.Date.ReadJson(); err != nil {
fmt.Println("static error")
err = service.Date.WriteJson()
if err != nil {
fmt.Println("static error")
return
}
}
service.TX(60 * 60 * 24 * 2)
go service.Ticker()
go service.TickerTX()
go service.Write()
r := gin.Default()
tmpl := template.Must(template.New("").ParseFS(f, "template/*.html"))
r.SetHTMLTemplate(tmpl)
r.GET("/", api.Loginx)
r.POST("/login", api.Login)
r.GET("/login", api.Login)
r.POST("/", api.Add)
r.POST("/del", api.Del)
r.POST("/put", api.Put)
if len(os.Args) > 1 {
r.Run(":" + os.Args[1])
} else {
r.Run(":8080")
}
}
// Ticker 定时任务
func init() {
err := service.Date.ReadJson()
if err != nil {
fmt.Println("static error")
return
}
}