From 41fa32958caf5ea37b9afd399b63dab0233d81b6 Mon Sep 17 00:00:00 2001 From: zogodo <742782908@qq.com> Date: Fri, 21 Feb 2020 01:13:14 +0800 Subject: [PATCH] =?UTF-8?q?material=20=E4=BC=BC=E4=B9=8E=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E4=BD=9C=E5=BC=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TC1/http_server/app_httpd.c | 68 +- TC1/http_server/app_httpd.h | 1 + TC1/http_server/test.py | 7 +- TC1/http_server/{ => web}/angular.min.js | 0 TC1/http_server/web/demo.html | 261 ++ TC1/http_server/{ => web}/index.html | 54 +- TC1/http_server/{ => web}/jquery.min.js | 0 .../web/material.cyan-light_blue.min.css | 8 + TC1/http_server/web/material.min.js | 10 + TC1/http_server/web/styles.css | 215 ++ TC1/http_server/web_data.c | 2922 +++++++++++++++-- 11 files changed, 3217 insertions(+), 329 deletions(-) rename TC1/http_server/{ => web}/angular.min.js (100%) create mode 100644 TC1/http_server/web/demo.html rename TC1/http_server/{ => web}/index.html (96%) rename TC1/http_server/{ => web}/jquery.min.js (100%) create mode 100644 TC1/http_server/web/material.cyan-light_blue.min.css create mode 100644 TC1/http_server/web/material.min.js create mode 100644 TC1/http_server/web/styles.css diff --git a/TC1/http_server/app_httpd.c b/TC1/http_server/app_httpd.c index e25b312..58cbcea 100644 --- a/TC1/http_server/app_httpd.c +++ b/TC1/http_server/app_httpd.c @@ -93,16 +93,28 @@ static int HttpGetIndexPage(httpd_request_t *req) { OSStatus err = kNoErr; - err = httpd_send_all_header(req, HTTP_RES_200, sizeof(index_html), HTTP_CONTENT_HTML_ZIP); + err = httpd_send_all_header(req, HTTP_RES_200, sizeof(web_index_html), HTTP_CONTENT_HTML_ZIP); require_noerr_action(err, exit, http_log("ERROR: Unable to send http wifisetting headers.")); - err = httpd_send_body(req->sock, index_html, sizeof(index_html)); + err = httpd_send_body(req->sock, web_index_html, sizeof(web_index_html)); require_noerr_action(err, exit, http_log("ERROR: Unable to send http wifisetting body.")); exit: return err; } +static int HttpGetDemoPage(httpd_request_t *req) +{ + OSStatus err = kNoErr; + err = httpd_send_all_header(req, HTTP_RES_200, sizeof(web_demo_html), HTTP_CONTENT_HTML_ZIP); + require_noerr_action(err, exit, http_log("ERROR: Unable to send http wifisetting headers.")); + + err = httpd_send_body(req->sock, web_demo_html, sizeof(web_demo_html)); + require_noerr_action(err, exit, http_log("ERROR: Unable to send http wifisetting body.")); +exit: + return err; +} + static int HttpGetJs(httpd_request_t *req) { OSStatus err = kNoErr; @@ -110,12 +122,17 @@ static int HttpGetJs(httpd_request_t *req) char* js_name = strstr(req->filename, "?name="); http_log("HttpDelTask url[%s] js_name[%s]", req->filename, js_name); - int total_sz = sizeof(jquery_min_js); - const unsigned char* js_data = jquery_min_js; + int total_sz = sizeof(web_jquery_min_js); + const unsigned char* js_data = web_jquery_min_js; if (strcmp(js_name + 6, "angular") == 0) { - total_sz = sizeof(angular_min_js); - js_data = angular_min_js; + total_sz = sizeof(web_angular_min_js); + js_data = web_angular_min_js; + } + if (strcmp(js_name + 6, "material") == 0) + { + total_sz = sizeof(web_material_min_js); + js_data = web_material_min_js; } err = httpd_send_all_header(req, HTTP_RES_200, total_sz, HTTP_CONTENT_JS_ZIP); @@ -124,22 +141,30 @@ static int HttpGetJs(httpd_request_t *req) err = httpd_send_body(req->sock, js_data, total_sz); require_noerr_action(err, exit, http_log("ERROR: Unable to send http wifisetting body.")); - /* - int i = 0; - int chunk_sz = 1000; - for (; i < total_sz; i += chunk_sz) +exit: + return err; +} + +static int HttpGetCss(httpd_request_t *req) +{ + OSStatus err = kNoErr; + + char* js_name = strstr(req->filename, "?name="); + http_log("HttpDelTask url[%s] js_name[%s]", req->filename, js_name); + + int total_sz = sizeof(web_styles_css); + const unsigned char* js_data = web_styles_css; + if (strcmp(js_name + 6, "material") == 0) { - if (i + chunk_sz >= total_sz) - { - chunk_sz = total_sz - i; - } - err = httpd_send_chunk(req->sock, (const char*)(angular_min_html + i), chunk_sz); - require_noerr_action(err, exit, http_log("ERROR: Unable to send http testpage body. i[%d] chunk_sz[%d] total_sz[%d]", i, chunk_sz, total_sz)); + total_sz = sizeof(web_material_cyan_light_blue_min_css); + js_data = web_material_cyan_light_blue_min_css; } - err = httpd_send_chunk(req->sock, NULL, 0); - require_noerr_action(err, exit, http_log("ERROR: Unable to send http testpage end.")); - http_log("httpd_send_chunk total_sz[%d] i[%d]", total_sz, i); - */ + + err = httpd_send_all_header(req, HTTP_RES_200, total_sz, HTTP_CONTENT_CSS_ZIP); + require_noerr_action(err, exit, http_log("ERROR: Unable to send http testpage headers.")); + + err = httpd_send_body(req->sock, js_data, total_sz); + require_noerr_action(err, exit, http_log("ERROR: Unable to send http wifisetting body.")); exit: return err; @@ -388,7 +413,9 @@ exit: const struct httpd_wsgi_call g_app_handlers[] = { { "/", HTTPD_HDR_DEFORT, 0, HttpGetIndexPage, NULL, NULL, NULL }, + { "/demo", HTTPD_HDR_DEFORT, 0, HttpGetDemoPage, NULL, NULL, NULL }, { "/js", HTTPD_HDR_DEFORT, 0, HttpGetJs, NULL, NULL, NULL }, + { "/css", HTTPD_HDR_DEFORT, 0, HttpGetCss, NULL, NULL, NULL }, { "/socket", HTTPD_HDR_DEFORT, 0, NULL, HttpSetSocketStatus, NULL, NULL }, { "/status", HTTPD_HDR_DEFORT, 0, HttpGetTc1Status, NULL, NULL, NULL }, { "/power", HTTPD_HDR_DEFORT, 0, NULL, HttpGetPowerInfo, NULL, NULL }, @@ -415,7 +442,6 @@ static int _AppHttpdStart() { OSStatus err = kNoErr; http_log("initializing web-services"); - http_log("sizeof(angular_min_js) = %d sizeof(jquery_min_js) = %d", sizeof(angular_min_js), sizeof(jquery_min_js)); /*Initialize HTTPD*/ if(is_http_init == false) { diff --git a/TC1/http_server/app_httpd.h b/TC1/http_server/app_httpd.h index 4b7db54..e028856 100644 --- a/TC1/http_server/app_httpd.h +++ b/TC1/http_server/app_httpd.h @@ -34,6 +34,7 @@ #define HTTP_CONTENT_HTML_ZIP "text/html\r\nContent-Encoding: gzip" #define HTTP_CONTENT_JS_ZIP "text/javascript\r\nContent-Encoding: gzip" +#define HTTP_CONTENT_CSS_ZIP "text/css\r\nContent-Encoding: gzip" #define HTTPD_HDR_DEFORT (HTTPD_HDR_ADD_SERVER|HTTPD_HDR_ADD_CONN_CLOSE|HTTPD_HDR_ADD_PRAGMA_NO_CACHE) diff --git a/TC1/http_server/test.py b/TC1/http_server/test.py index 4ebeb95..0a11be3 100644 --- a/TC1/http_server/test.py +++ b/TC1/http_server/test.py @@ -27,8 +27,11 @@ def gen(fn): fn = re.sub(r"[^\w]", "_", fn) print("const unsigned char %s[0x%x] = {\n%s};" % (fn, len(dat), s)) -for fn in glob.glob('*.html'): +for fn in glob.glob('web/*.html'): gen(fn) -for fn in glob.glob('*.js'): +for fn in glob.glob('web/*.js'): + gen(fn) + +for fn in glob.glob('web/*.css'): gen(fn) diff --git a/TC1/http_server/angular.min.js b/TC1/http_server/web/angular.min.js similarity index 100% rename from TC1/http_server/angular.min.js rename to TC1/http_server/web/angular.min.js diff --git a/TC1/http_server/web/demo.html b/TC1/http_server/web/demo.html new file mode 100644 index 0000000..d3cdabb --- /dev/null +++ b/TC1/http_server/web/demo.html @@ -0,0 +1,261 @@ + + + + + + + + + Material Design Lite + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Home +
+
+ +
+ + +
+
+ +
    +
  • About
  • +
  • Contact
  • +
  • Legal information
  • +
+
+
+
+
+ +
+ hello@example.com +
+ +
    +
  • hello@example.com
  • +
  • info@example.com
  • +
  • addAdd another account...
  • +
+
+
+ +
+
+
+
+ + + 82% + + + + 82% + + + + 82% + + + + 82% + +
+
+ + + + + + +
+
+
+
+

Updates

+
+
+ Non dolore elit adipisicing ea reprehenderit consectetur culpa. +
+
+ Read More +
+
+
+
+
+

View options

+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+ + +
+
+ Change location +
+ location_on +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + 500 + 400 + 300 + 200 + 100 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + + + + + + + + + + + View Source + + + + + + diff --git a/TC1/http_server/index.html b/TC1/http_server/web/index.html similarity index 96% rename from TC1/http_server/index.html rename to TC1/http_server/web/index.html index 4969a0b..0e89e88 100644 --- a/TC1/http_server/index.html +++ b/TC1/http_server/web/index.html @@ -4,6 +4,7 @@ Welcom TC1 +