-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
27 lines (22 loc) · 799 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
package main
import (
"flag"
"net/http"
"go-gpt-server/api"
"go-gpt-server/middle"
)
func main() {
var clearConvs bool
flag.BoolVar(&clearConvs, "clear", false, "clear all conversations")
flag.BoolVar(&api.MultiSession, "multi", false, "support multi conversations")
flag.Parse()
if clearConvs {
api.ClearConvs()
}
http.Handle("/event", middle.EnableCors(middle.HandleOptions(http.HandlerFunc(api.HandleSSE))))
http.Handle("/token", http.HandlerFunc(api.GenToken))
http.Handle("/chat", middle.EnableCors(middle.HandleOptions(middle.AuthMiddleware(http.HandlerFunc(api.HandleChat)))))
http.Handle("/conv", middle.EnableCors(middle.HandleOptions(middle.AuthMiddleware(http.HandlerFunc(api.HandleConv)))))
println("Welcome to the gpt server")
http.ListenAndServe(":8000", nil)
}