- Added margin for alerts

- Bootstrap css gzip
This commit is contained in:
Rene Zeldenthuis
2022-09-20 15:06:05 +02:00
parent cbdea51a12
commit e69f33c6a2
4 changed files with 14 additions and 22 deletions

View File

@@ -42,18 +42,13 @@ bool config_changed = false;
// Camera initialization result
esp_err_t camera_init_result;
void stream_text_file(const char *content, const char *mime_type)
{
// Cache for 86400 seconds (one day)
web_server.sendHeader("Cache-Control", "max-age=86400");
web_server.send(200, mime_type, content);
}
void stream_text_file_gzip(const unsigned char *content, size_t length, const char *mime_type)
{
// Cache for 86400 seconds (one day)
web_server.sendHeader("Cache-Control", "max-age=86400");
web_server.sendContent(mime_type);
web_server.sendHeader("Content-encoding", "gzip");
web_server.setContentLength(length);
web_server.send(200, mime_type, "");
web_server.sendContent(reinterpret_cast<const char *>(content), length);
}
@@ -146,14 +141,13 @@ void handle_snapshot()
return;
}
web_server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
web_server.sendContent("HTTP/1.1 200 OK\r\n"
"Content-Disposition: inline; filename=snapshot.jpg\r\n"
"Content-Type: image/jpeg\r\n\r\n");
// Make a copy in memory to prevent interaction with RTSP
auto fb_len = cam.getSize();
cam.run();
auto fb_len = cam.getSize();
auto fb = (uint8_t *)memcpy(new uint8_t[cam.getSize()], cam.getfb(), fb_len);
web_server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
web_server.setContentLength(fb_len);
web_server.send(200, "image/jpeg", "");
web_server.sendContent(reinterpret_cast<const char *>(fb), fb_len);
delete[] fb;
}
@@ -246,9 +240,7 @@ void setup()
// bootstrap
web_server.on("/bootstrap.min.css", HTTP_GET, []()
{
web_server.sendHeader("Content-encoding", "gzip");
stream_text_file_gzip(file_data_bootstrap_min_css, sizeof(file_data_bootstrap_min_css), "text/css"); });
{ stream_text_file_gzip(file_data_bootstrap_min_css, sizeof(file_data_bootstrap_min_css), "text/css"); });
web_server.onNotFound([]()
{ iotWebConf.handleNotFound(); });