如何从基于ESP8266的服务器发送巨大的html文件

时间:2018-10-27 10:23:08

标签: arduino esp8266 nodemcu arduino-esp8266 esp32

是否可以从基于ESP8266(NodeMCU v1.0)的服务器向客户端浏览器发送高达200Kb的html文件。

当前,我正在使用以下方法:

  1. html页面已分配给char数组

    const char myPage[] PROGMEM = R"=====( <my html page with javascript> )=====";

  2. 根据请求将页面发送给客户端

    ESP8266WebServer server(80);

    server.on("/", handleRoot);

    handleRoot(){ String page = myPage; server.send(200, 'text/html', page); }

从浏览器中访问URL时,响应标题中将显示以下内容:

Cache-Control: no-cache
Connection: close
Content-Length: 0
Content-Type: text/html

这种方法适用于10至15 Kb的较小文件(根据我的测试)。

0 个答案:

没有答案