viewing logs in webserver
This commit is contained in:
parent
26a677be53
commit
7e57d2de36
3 changed files with 42 additions and 0 deletions
22
server.py
22
server.py
|
@ -300,6 +300,28 @@ def send_static(path):
|
||||||
return send_from_directory('ui-static', path)
|
return send_from_directory('ui-static', path)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/logs")
|
||||||
|
def list_logs():
|
||||||
|
data = {
|
||||||
|
"ui_page": "loglist",
|
||||||
|
"ui_title": "Logs",
|
||||||
|
"logs": ["BAPSicleServer"] + ["channel{}".format(x) for x in range(state.state["num_channels"])]
|
||||||
|
}
|
||||||
|
return render_template("loglist.html", data=data)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/logs/<path:path>")
|
||||||
|
def send_logs(path):
|
||||||
|
l = open("logs/{}.log".format(path))
|
||||||
|
data = {
|
||||||
|
"logs": l.read().splitlines(),
|
||||||
|
'ui_page': "log",
|
||||||
|
"ui_title": "Logs - {}".format(path)
|
||||||
|
}
|
||||||
|
l.close()
|
||||||
|
return render_template('log.html', data=data)
|
||||||
|
|
||||||
|
|
||||||
def startServer():
|
def startServer():
|
||||||
if isMacOS():
|
if isMacOS():
|
||||||
multiprocessing.set_start_method("spawn", True)
|
multiprocessing.set_start_method("spawn", True)
|
||||||
|
|
11
templates/log.html
Normal file
11
templates/log.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block content_inner %}
|
||||||
|
{% if data %}
|
||||||
|
{% for log in data.logs %}
|
||||||
|
<code>
|
||||||
|
{{log}}
|
||||||
|
</code>
|
||||||
|
<br>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
9
templates/loglist.html
Normal file
9
templates/loglist.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block content_inner %}
|
||||||
|
{% if data %}
|
||||||
|
{% for log in data.logs %}
|
||||||
|
<a href="/logs/{{log}}">{{log}}</a>
|
||||||
|
<br>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
Loading…
Reference in a new issue