import (
"http";
"io";
- "./dbibridge";
+ //"./dbibridge";
+ "./benchcontroller";
+ //"dbconnector";
+ "fmt";
+ "json";
)
-// hello world, the web server
-func HelloServer(c *http.Conn, req *http.Request) {
- io.WriteString(c, "<html><form method=post><input type=\"input\"><input type=\"submit\" name=\"go\" value=\"go\"></html>\n");
+type JSONStatData struct {
+ currentJob int; // 1 = nothing, 2 = have database login, 3 = createing data, 4 = running test, 5 = finished
+ currentStatus int; // percent complete
}
-func main() {
- dbibridge.dbiconnect();
- http.Handle("/hello", http.HandlerFunc(HelloServer));
- err := http.ListenAndServe(":12345", nil);
+var comin chan string;
+var cominstatus chan string;
+var comout chan string;
+
+func JSONResponder(c *http.Conn, req *http.Request)
+{
+ //stat := <- cominstatus;
+
+ if(req.Method == "GET") {
+
+ j, _, _ := json.StringToJson("{\"status\":1, \"complete\":90}");
+
+ io.WriteString(c, fmt.Sprintf("%s\n", json.JsonToString(j)));
+ fmt.Printf("i got a get\n");
+ }
+ if(req.Method == "POST") {
+ fmt.Printf("i got a post...\n");
+ http.Redirect(c, "/", 301);
+ }
+
+}
+
+
+func header(c *http.Conn)
+{
+ io.WriteString(c, "<html><head></head><body>");
+}
+
+func footer(c *http.Conn)
+{
+ io.WriteString(c, "</body></html>");
+}
+
+func main()
+{
+ comin = make(chan string);
+ cominstatus = make(chan string);
+ comout = make(chan string);
+
+
+ bc := benchcontroller.CreateController();
+ go benchcontroller.MainLoop(bc, comout, comin, cominstatus);
+
+ http.Handle("/", http.FileServer("./web/", "/"));
+ http.Handle("/json", http.HandlerFunc(JSONResponder));
+ err := http.ListenAndServe(":22222", nil);
if err != nil {
panic("ListenAndServe: ", err.String())
}