overview_add_date_and_time (#3398)

* overview_add_date_and_time

* Update overview.html

---------

Co-authored-by: CaCO3 <caco3@ruinelli.ch>
This commit is contained in:
SybexX
2024-12-02 00:26:54 +01:00
committed by GitHub
parent 3f4aaf303f
commit 9e84d28ee9
3 changed files with 44 additions and 1 deletions

View File

@@ -1487,6 +1487,28 @@ esp_err_t handler_rssi(httpd_req_t *req)
return ESP_OK;
}
esp_err_t handler_current_date(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_uptime - Start");
#endif
std::string formatedDateAndTime = getCurrentTimeString("%Y-%m-%d %H:%M:%S");
// std::string formatedDate = getCurrentTimeString("%Y-%m-%d");
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
httpd_resp_send(req, formatedDateAndTime.c_str(), formatedDateAndTime.length());
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_sendstr_chunk(req, NULL);
#ifdef DEBUG_DETAIL_ON
LogFile.WriteHeapInfo("handler_uptime - End");
#endif
return ESP_OK;
}
esp_err_t handler_uptime(httpd_req_t *req)
{
#ifdef DEBUG_DETAIL_ON
@@ -1798,6 +1820,11 @@ void register_server_main_flow_task_uri(httpd_handle_t server)
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/date";
camuri.handler = handler_current_date;
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);
camuri.uri = "/uptime";
camuri.handler = handler_uptime;
camuri.user_ctx = (void *)"Light Off";