separate html_index.h

This commit is contained in:
Devaev Maxim 2018-11-03 03:31:10 +03:00
parent 5a7f3d30a7
commit 8be5d6d370
2 changed files with 65 additions and 8 deletions

63
src/data/html_index.h Normal file
View File

@ -0,0 +1,63 @@
/*****************************************************************************
# uStreamer - Lightweight and fast MJPG-HTTP streamer. #
# #
# Copyright (C) 2018 Maxim Devaev <mdevaev@gmail.com> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# #
*****************************************************************************/
#pragma once
#include "../config.h"
const char *HTML_INDEX_PAGE = " \
<!DOCTYPE html> \
<html> \
<head> \
<meta charset=\"utf-8\"> \
<title>uStreamer</title> \
</head> \
<body> \
<ul> \
<li> \
<a href=\"/ping\"><b>/ping</b></a><br> \
Get JSON structure with state of the server. \
</li> \
<hr><br> \
<li> \
<a href=\"/snapshot\"><b>/snapshot</b></a><br> \
Get a current actual image from server. \
</li> \
<hr><br> \
<li> \
<a href=\"/stream\"><b>/stream</b></a><br> \
Get a live stream. Query params: \
<ul> \
<li> \
<i>advance_headers=1</i><br> \
Enable workaround for Chromium/Blink \
<a href=\"https://bugs.chromium.org/p/chromium/issues/detail?id=527446\">Bug #527446</a>. \
</li> \
</ul> \
</li> \
<br> \
</ul> \
<hr> \
&nbsp;&nbsp;&nbsp;&nbsp; &micro;Streamer v" VERSION " \
</body> \
</html> \
";

View File

@ -43,6 +43,7 @@
#include "stream.h"
#include "http.h"
#include "data/html_index.h"
#include "data/blank.h"
@ -172,14 +173,7 @@ static void _http_callback_root(struct evhttp_request *request, UNUSED void *arg
PROCESS_HEAD_REQUEST;
assert((buf = evbuffer_new()));
assert(evbuffer_add_printf(buf,
"<!DOCTYPE html><html><head><meta charset=\"utf-8\">"
"<title>uStreamer</title></head><body><ul>"
"<li><a href=\"/ping\">/ping</a></li>"
"<li><a href=\"/snapshot\">/snapshot</a></li>"
"<li><a href=\"/stream\">/stream</a></li>"
"</body></html>"
));
assert(evbuffer_add_printf(buf, HTML_INDEX_PAGE));
ADD_HEADER("Content-Type", "text/html");
evhttp_send_reply(request, HTTP_OK, "OK", buf);
evbuffer_free(buf);