Add content to default web page

This commit is contained in:
badaix 2020-10-27 08:30:36 +01:00
parent 701502394e
commit a7c945ad53
2 changed files with 87 additions and 2 deletions

View file

@ -30,6 +30,38 @@ static constexpr auto LOG_TAG = "ControlSessionHTTP";
static constexpr const char* HTTP_SERVER_NAME = "Snapcast";
static constexpr const char* UNCONFIGURED =
"<html><head><title>Snapcast Default Page</title></head>"
"<body>"
" <h1>Snapcast Default Page</h1>"
" <p>"
" This is the default welcome page used to test the correct operation of the Snapcast built-in webserver."
" </p>"
" <p>"
" This webserver is a websocket endpoint for control clients (ws://<i>host</i>:1780/jsonrpc) and streaming clients"
" (ws://<i>host</i>:1780/stream), but it can also host simple web pages. To serve a web page, you must configure the"
" document root in the snapserver configuration file <b>snapserver.conf</b>, usually located in"
" <b>/etc/snapserver.conf</b>"
" </p>"
" <p>"
" The Snapserver installation should include a copy of <a href=\"https://github.com/badaix/snapweb\">Snapweb</a>,"
" located in <b>/usr/share/snapserver/snapweb/</b><br>"
" To activate it, please configure the <b>doc_root</b> as follows, and restart Snapserver to activate the changes:"
" </p>"
" <pre>"
"# HTTP RPC #####################################\n"
"#\n"
"[http]\n"
"\n"
"...\n"
"\n"
"# serve a website from the doc_root location\n"
"doc_root = /usr/share/snapserver/snapweb/\n"
"\n"
"#\n"
"################################################</pre>"
"</body>"
"</html>";
namespace
{
@ -161,7 +193,7 @@ void ControlSessionHttp::handle_request(http::request<Body, http::basic_fields<A
res.set(http::field::server, HTTP_SERVER_NAME);
res.set(http::field::content_type, "text/html");
res.keep_alive(req.keep_alive());
res.body() = "<html><head><title>Snapcast Default Page</title></head><body>TODO: description how to configure the doc_root</body></html>";
res.body() = UNCONFIGURED;
res.prepare_payload();
return res;
};

View file

@ -2,10 +2,63 @@
<head>
<title>Snapcast Default Page</title>
<style>
body {
background: #ffffff;
color: rgb(0, 0, 0);
font-family: 'Arial', sans-serif;
margin: 20px;
font-size: 20px;
}
pre {
margin: 8px 0px 8px 0px;
padding: 20px;
border-width: 1px;
border-style: dotted;
border-color: #000000;
background-color: #F5F6F7;
font-style: italic;
display: inline-block;
}
h1 {
margin: 15px 0px 0px 50px;
font-size: 180%;
font-weight: bold;
}
</style>
</head>
<body>
TODO: description how to configure the doc_root
<h1>Snapcast Default Page</h1>
<p>
This is the default welcome page used to test the correct operation of the Snapcast built-in webserver.
</p>
<p>
This webserver is a websocket endpoint for control clients (ws://<i>host</i>:1780/jsonrpc) and streaming clients
(ws://<i>host</i>:1780/stream), but it can also host simple web pages. To serve a web page, you must configure the
document root in the snapserver configuration file <b>snapserver.conf</b>, usually located in
<b>/etc/snapserver.conf</b>
</p>
<p>
The Snapserver installation should include a copy of <a href="https://github.com/badaix/snapweb">Snapweb</a>,
located in
<b>/usr/share/snapserver/snapweb/</b><br>
To activate it, please configure the <b>doc_root</b> as follows, and restart Snapserver to activate the changes:
</p>
<pre>
# HTTP RPC #####################################
#
[http]
...
# serve a website from the doc_root location
doc_root = /usr/share/snapserver/snapweb/
#
################################################</pre>
</body>
</html>