1
0
mirror of https://github.com/craigerl/aprsd.git synced 2024-12-20 00:26:04 -05:00

Added aprsd web index page

This patch adds an index page for the flask web server that users
can hit at /
This commit is contained in:
Hemna 2021-03-24 10:45:03 -04:00
parent 53cdccde10
commit f211e5cabb
2 changed files with 43 additions and 4 deletions

View File

@ -40,8 +40,7 @@ class APRSDFlask(flask_classful.FlaskView):
users = self.users
def index(self):
return "Hello"
# return flask.render_template("index.html", message=msg)
return flask.render_template("index.html", message=self.stats())
@auth.login_required
def messages(self):
@ -89,7 +88,7 @@ def init_flask(config):
)
server = APRSDFlask()
server.set_config(config)
# flask_app.route('/', methods=['GET'])(server.index)
flask_app.route("/", methods=["GET"])(server.index)
flask_app.route("/stats", methods=["GET"])(server.stats)
flask_app.route("/messages", methods=["GET"])(server.messages)
flask_app.route("/save", methods=["GET"])(server.save)

View File

@ -1,4 +1,44 @@
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<body><h1>{{ message }}</h1></body>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/components/prism-json.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-tomorrow.css">
<script type="text/javascript"">
function start_update() {
(function statsworker() {
$.ajax({
url: "/stats",
type: 'GET',
dataType: 'json',
success: function(data) {
//data = JSON.parse(response)
const html_pretty = Prism.highlight(JSON.stringify(data, null, '\t'), Prism.languages.json, 'json');
$("#app").html(html_pretty)
},
complete: function() {
setTimeout(statsworker, 60000);
}
});
})();
}
$(document).ready(function() {
$("#app").text("Starting PEEPIS")
start_update();
});
</script>
</head>
<body>
<pre id="app" class="language-json">{{ stats }}</pre>
<canvas id="messsageChart"></canvas>
</body>
</html>