Simple HTTP Server with one page index.html stored inside MBED as char vector and javascript to update a table content

Fork of HTTP_SERVER by Akifumi Takahashi

Revision:
13:b6dd6ed0060b
Parent:
11:0ee7d100db24
--- a/handlers/Filehandler.cpp	Fri Mar 16 21:50:43 2018 +0000
+++ b/handlers/Filehandler.cpp	Fri Mar 16 21:55:50 2018 +0000
@@ -1,6 +1,6 @@
 #include "FileHandler.h"
 #ifndef DEBUG
-#define DEBUG
+//#define DEBUG
 #endif
 LocalFileSystem local("local");
 
@@ -25,11 +25,11 @@
 {
     FILE *tmp;
 
-    printf("\r\n"
-           "fp: %d@FileHandler::open\r\n", fp);
+    //////printf("\r\n"
+    //       "fp: %d@FileHandler::open\r\n", fp);
     if (fullpath != NULL) free(fullpath);
     fullpath = (char*)malloc(sizeof(char) * (strlen("/local/") + strlen(arg_filepath) + strlen("index.htm") + 1));
-    printf("fp: %d@FileHandler::open\r\n", fp);
+    //////printf("fp: %d@FileHandler::open\r\n", fp);
 
     //  Path formatting
     if (arg_filepath[0] == '/') {
@@ -47,31 +47,31 @@
     suffix = strchr(filename, '.');
     if(suffix   != NULL)    suffix++;   //  remove '.' and just get only the suffix.
 #ifdef DEBUG
-    printf("full path: %s\r\nfilename: %s\r\nsuffix: %s\r\n", getFullpath(), getFilename(), getSuffix());
+    //////printf("full path: %s\r\nfilename: %s\r\nsuffix: %s\r\n", getFullpath(), getFilename(), getSuffix());
 #endif
     fp = fopen(fullpath, arg_mode);
 #ifdef DEBUG
-    printf("file opened@FileHandler::open\r\n");
+    //////////printf("file opened@FileHandler::open\r\n");
 #endif
     //  mesure file size
     file_size = 0;
     tmp = fp;
     if(tmp != NULL ) {
-        printf("\r\nfile content\r\n");
+        ////printf("\r\nfile content\r\n");
         int ctmp;
         while(1) {
             ctmp = fgetc(tmp);
             if(ctmp != EOF) {
-                printf("%c", ctmp);
+                //////printf("%c", ctmp);
                 file_size++;
             } else {
-                printf("[EOF]\r\n");
+                //////printf("[EOF]\r\n");
                 break;
             }
         }
-        printf("file size: %d\r\n", file_size);
+        ////printf("file size: %d\r\n", file_size);
         if(fseek(tmp, 0L, SEEK_SET) != 0) {
-            printf("fseek failed\r\n");
+            //////printf("fseek failed\r\n");
         }
     } else {
         file_size = 0;
@@ -95,7 +95,7 @@
 int FileHandler::getc()
 {
     int tmp = fgetc(fp);
-
+#ifdef DEBUG
     if(0x20 < tmp && tmp < 0x7e)
         printf("%c", tmp);
     else if (tmp == '\r')
@@ -104,8 +104,8 @@
         printf("\n");
     else
         printf("@");
-
-    return tmp;//fgetc(fp);
+#endif
+    return tmp;
 }
 bool FileHandler::arrival()
 {