mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-13 11:03:43 +00:00
static html generator
This commit is contained in:
1
Makefile
1
Makefile
@@ -30,6 +30,7 @@ install: $(PROG)
|
|||||||
|
|
||||||
regen:
|
regen:
|
||||||
tools/make-jpg-h.py src/data/blank.jpg src/data/blank.h BLANK 640 480
|
tools/make-jpg-h.py src/data/blank.jpg src/data/blank.h BLANK 640 480
|
||||||
|
tools/make-html-h.py src/data/index.html src/data/html_index.h HTML_INDEX_PAGE
|
||||||
|
|
||||||
|
|
||||||
$(PROG): $(OBJECTS)
|
$(PROG): $(OBJECTS)
|
||||||
|
|||||||
@@ -26,11 +26,13 @@
|
|||||||
|
|
||||||
const char *HTML_INDEX_PAGE = " \
|
const char *HTML_INDEX_PAGE = " \
|
||||||
<!DOCTYPE html> \
|
<!DOCTYPE html> \
|
||||||
|
\
|
||||||
<html> \
|
<html> \
|
||||||
<head> \
|
<head> \
|
||||||
<meta charset=\"utf-8\"> \
|
<meta charset=\"utf-8\"> \
|
||||||
<title>uStreamer</title> \
|
<title>uStreamer</title> \
|
||||||
</head> \
|
</head> \
|
||||||
|
\
|
||||||
<body> \
|
<body> \
|
||||||
<h3>µStreamer v" VERSION "</h3> \
|
<h3>µStreamer v" VERSION "</h3> \
|
||||||
<hr> \
|
<hr> \
|
||||||
|
|||||||
46
src/data/index.html
Normal file
46
src/data/index.html
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset=\"utf-8\">
|
||||||
|
<title>uStreamer</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h3>µStreamer v%VERSION%</h3>
|
||||||
|
<hr>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href=\"/ping\"><b>/ping</b></a><br>
|
||||||
|
Get JSON structure with state of the server.
|
||||||
|
</li>
|
||||||
|
<br>
|
||||||
|
<li>
|
||||||
|
<a href=\"/snapshot\"><b>/snapshot</b></a><br>
|
||||||
|
Get a current actual image from server.
|
||||||
|
</li>
|
||||||
|
<br>
|
||||||
|
<li>
|
||||||
|
<a href=\"/stream\"><b>/stream</b></a><br>
|
||||||
|
Get a live stream. Query params:<br>
|
||||||
|
<br>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<i>extra_headers=1</i><br>
|
||||||
|
Add X-UStreamer-* headers to /stream handle (like on <a href=\"/snapshot\">/snapshot</a>).
|
||||||
|
</li>
|
||||||
|
<br>
|
||||||
|
<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>
|
||||||
|
<br>
|
||||||
|
<hr>
|
||||||
|
<a href=\"https://github.com/pi-kvm/ustreamer\">Sources & docs</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
77
tools/make-html-h.py
Executable file
77
tools/make-html-h.py
Executable file
@@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#============================================================================#
|
||||||
|
# #
|
||||||
|
# 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/>. #
|
||||||
|
# #
|
||||||
|
#============================================================================#
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
|
||||||
|
# =====
|
||||||
|
def main():
|
||||||
|
assert len(sys.argv) == 4, "%s <src> <dest> <name>" % (sys.argv[0])
|
||||||
|
|
||||||
|
src = sys.argv[1]
|
||||||
|
dest = sys.argv[2]
|
||||||
|
name = sys.argv[3]
|
||||||
|
|
||||||
|
with open(src, "r") as html_file:
|
||||||
|
text = html_file.read()
|
||||||
|
|
||||||
|
text = text.strip()
|
||||||
|
text = text.replace("%VERSION%", "\" VERSION \"")
|
||||||
|
text = textwrap.indent(text, "\t", (lambda line: True))
|
||||||
|
text = "\n".join(("%s \\" if line.strip() else "%s\\") % (line) for line in text.split("\n"))
|
||||||
|
text = "const char *%s = \" \\\n%s\n\";\n" % (name, text)
|
||||||
|
text = textwrap.dedent("""
|
||||||
|
/*****************************************************************************
|
||||||
|
# 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"
|
||||||
|
""").strip() + "\n\n\n" + text
|
||||||
|
|
||||||
|
with open(dest, "w") as h_file:
|
||||||
|
h_file.write(text)
|
||||||
|
|
||||||
|
|
||||||
|
# =====
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user