Просмотр исходного кода

Return a complete UTF-8 document for recognition view

SybexXx 1 день назад
Родитель
Сommit
0c906d57ca
1 измененных файлов с 13 добавлено и 3 удалено
  1. 13 3
      code/components/jomjol_flowcontroll/MainFlowControl.cpp

+ 13 - 3
code/components/jomjol_flowcontroll/MainFlowControl.cpp

@@ -671,7 +671,8 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
         if (query.find("full") != std::string::npos)
         if (query.find("full") != std::string::npos)
         {
         {
             std::string txt;
             std::string txt;
-            txt = "<body style=\"font-family: arial\">";
+            httpd_resp_set_type(req, "text/html; charset=utf-8");
+            txt = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"></head><body style=\"font-family: arial\">";
 
 
             if ((countRounds <= 1) && (status != std::string("Flow finished")))
             if ((countRounds <= 1) && (status != std::string("Flow finished")))
             {
             {
@@ -686,6 +687,11 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
             httpd_resp_sendstr_chunk(req, txt.c_str());
             httpd_resp_sendstr_chunk(req, txt.c_str());
         }
         }
 
 
+        if (query.find("full") == std::string::npos)
+        {
+            httpd_resp_set_type(req, "text/plain");
+        }
+
         zw = flowctrl.getReadout(_rawValue, _noerror, 0);
         zw = flowctrl.getReadout(_rawValue, _noerror, 0);
 
 
         if (zw.length() > 0)
         if (zw.length() > 0)
@@ -705,8 +711,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
             else
             else
             {
             {
                 /* Digit ROIs */
                 /* Digit ROIs */
-                txt = "<body style=\"font-family: arial\">";
-                txt += "<hr><h3>Recognized Digit ROIs (previous round)</h3>\n";
+                txt = "<hr><h3>Recognized Digit ROIs (previous round)</h3>\n";
                 txt += "<table style=\"border-spacing: 5px\"><tr style=\"text-align: center; vertical-align: top;\">\n";
                 txt += "<table style=\"border-spacing: 5px\"><tr style=\"text-align: center; vertical-align: top;\">\n";
 
 
                 std::vector<HTMLInfo *> htmlinfodig;
                 std::vector<HTMLInfo *> htmlinfodig;
@@ -796,6 +801,11 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
             }
             }
         }
         }
 
 
+        if (query.find("full") != std::string::npos)
+        {
+            httpd_resp_sendstr_chunk(req, "</body></html>");
+        }
+
         /* Respond with an empty chunk to signal HTTP response completion */
         /* Respond with an empty chunk to signal HTTP response completion */
         httpd_resp_sendstr_chunk(req, NULL);
         httpd_resp_sendstr_chunk(req, NULL);
     }
     }