优化日志及config

This commit is contained in:
hoteas
2022-07-11 19:13:20 +08:00
parent f37b9aee70
commit 8f7380d796
6 changed files with 119 additions and 81 deletions
+7 -3
View File
@@ -16,8 +16,12 @@
}
],
"db": {
"sqlite": {
"path": "config/data.db"
"mysql": {
"host": "127.0.0.1",
"name": "gov_crawler",
"password": "root",
"port": "3306",
"user": "root"
}
},
"defFile": [
@@ -32,7 +36,7 @@
"5": "数据结果异常"
},
"mode": 2,
"port": "80",
"port": "8081",
"sessionName": "HOTIME",
"tpt": "tpt"
}
+28 -7
View File
@@ -4,6 +4,7 @@ import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
"fmt"
"golang.org/x/net/websocket"
)
func main() {
@@ -13,15 +14,35 @@ func main() {
"user": Ctr{
"test": func(that *Context) {
fmt.Println("dasdasd")
id := that.Db.Insert("user", Map{"name": "test"})
ok := that.Db.Update("user", Map{"name": "test1"}, Map{"name": "test"})
//id := that.Db.Insert("user", Map{"name": "test"})
//ok := that.Db.Update("user", Map{"name": "test1"}, Map{"name": "test"})
ps := that.Db.Select("user", "*")
p := that.Db.Get("user", "*")
row := that.Db.Delete("user", Map{"id": id})
that.Display(0, Slice{id, ok, ps, p, row})
//row := that.Db.Delete("user", Map{"id": id})
//that.Display(0, Slice{id, ok, ps, p, row})
that.Display(0, Slice{ps, p})
},
},
},
})
"websocket": func(that *Context) {
hdler := websocket.Handler(func(ws *websocket.Conn) {
for true {
msg := make([]byte, 5120)
n, err := ws.Read(msg)
if err != nil {
return
}
fmt.Printf("Receive: %s\n", msg[:n])
send_msg := "[" + string(msg[:n]) + "]"
m, err := ws.Write([]byte(send_msg))
if err != nil {
return
}
fmt.Printf("Send: %s\n", msg[:m])
}
})
hdler.ServeHTTP(that.Resp, that.Req)
},
}}})
}