forked from aurora-develop/aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (35 loc) · 774 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 (
"freechatgpt/internal/tokens"
"github.com/acheong08/endless"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"os"
)
var HOST string
var PORT string
var ACCESS_TOKENS tokens.AccessToken
var proxies []string = []string{"http://127.0.0.1:7890"}
func init() {
_ = godotenv.Load(".env")
HOST = os.Getenv("SERVER_HOST")
PORT = os.Getenv("SERVER_PORT")
if HOST == "" {
HOST = "127.0.0.1"
}
if PORT == "" {
PORT = "8080"
}
}
func main() {
router := gin.Default()
router.Use(cors)
router.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
router.OPTIONS("/v1/chat/completions", optionsHandler)
router.POST("/v1/chat/completions", nightmare)
endless.ListenAndServe(HOST+":"+PORT, router)
}