-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
42 lines (37 loc) · 915 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
package main
import (
"Ugle/api"
"Ugle/db"
//"Ugle/utils"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"io"
"os"
"net/http"
)
func ApiCache(url string, file string) {
resp, err := http.Get(url)
if err != nil {
panic(err)
return
}
defer resp.Body.Close()
out, err := os.Create(file)
if err != nil {
// panic?
}
defer out.Close()
io.Copy(out, resp.Body)
}
func main() {
ApiCache("https://raw.githubusercontent.com/ucanet/ucanet-registry/main/ucanet-registry.txt", "./registry/registry.txt")
ApiCache("http://ucanet.net/sitelist.txt", "./registry/sitelist.txt")
db.Init()
//utils.CreateDatabaseFromRegistry()
//WILL INDEX ALL SITES, ATTENTION!!!!! ^^^^^
router := gin.Default()
router.TrustedPlatform = gin.PlatformCloudflare
router.GET("/search", api.MongoApiSearch)
router.Use(static.Serve("/", static.LocalFile("./static", false)))
router.Run("127.0.0.1:80")
}