16 type JSONStatData struct {
17 currentJob int; // 1 = nothing, 2 = have database login, 3 = createing data, 4 = running test, 5 = finished
18 currentStatus int; // percent complete
21 var comin chan string;
22 var cominstatus chan string;
23 var comout chan string;
25 func JSONResponder(c *http.Conn, req *http.Request)
27 //stat := <- cominstatus;
29 if(req.Method == "GET") {
31 j, _, _ := json.StringToJson("{\"status\":1, \"complete\":90}");
33 io.WriteString(c, fmt.Sprintf("%s\n", json.JsonToString(j)));
34 fmt.Printf("i got a get\n");
36 if(req.Method == "POST") {
37 fmt.Printf("i got a post...\n");
38 http.Redirect(c, "/", 301);
44 func header(c *http.Conn)
46 io.WriteString(c, "<html><head></head><body>");
49 func footer(c *http.Conn)
51 io.WriteString(c, "</body></html>");
56 comin = make(chan string);
57 cominstatus = make(chan string);
58 comout = make(chan string);
61 bc := benchcontroller.CreateController();
62 go benchcontroller.MainLoop(bc, comout, comin, cominstatus);
64 http.Handle("/", http.FileServer("./web/", "/"));
65 http.Handle("/json", http.HandlerFunc(JSONResponder));
66 err := http.ListenAndServe(":22222", nil);
68 panic("ListenAndServe: ", err.String())