numberImgRecognition/goVersion/server.go
goVersion/server.goRaw
1package main
2
3/*
4type NumberImg struct {
5 File string `json: "file"`
6 Text string `json: "text"`
7}
8
9func runServer() {
10 router := mux.NewRouter().StrictSlash(true)
11 router.HandleFunc("/", Index).Methods("GET")
12 router.HandleFunc("/img", ImgToNumber).Methods("POST")
13 log.Fatal(http.ListenAndServe(":3020", router))
14}
15func Index(w http.ResponseWriter, r *http.Request) {
16 fmt.Println(r.URL.Path)
17 fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
18}
19func ImgToNumber(w http.ResponseWriter, r *http.Request) {
20 fmt.Println(r.URL.Path)
21 decoder := json.NewDecoder(r.Body)
22
23 var t NumberImg
24 err := decoder.Decode(&t)
25
26 if err != nil {
27 panic(err)
28 }
29
30 fmt.Println(t.Text)
31 fmt.Fprintf(w, "data")
32}*/