* # License
* Copyright 2019 Silicon Laboratories Inc.
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
#include "gos.h"
static const char webpage_body[] =
"<!DOCTYPE html>"
"<title>HTTP Server Example</title>"
"<h1>Dynamic Root Webpage</h1>"
"<p>Current time: %s</p>"
gos_result_t root_page_request(const gos_hs_request_t *request, const char *arg)
gos_result_t result;
char html_page[sizeof(webpage_body) + sizeof(gos_iso8601_str_t)];
const int len = sprintf(html_page, webpage_body, (const char*)&time_str);
if (GOS_FAILED(result, gos_hs_write_reply_header(request, "text/html", len, GOS_HS_RESPONSE_FLAG_NONE)))
else if (GOS_FAILED(result, gos_hs_write_data(request, html_page, len, true)))
return result;