Skip to content
Snippets Groups Projects
Commit 4cb90a7b authored by Xin-Hao Zhu's avatar Xin-Hao Zhu
Browse files

Use Response instead of render_template to ensure latest HTML

parent a8b8caef
No related branches found
No related tags found
No related merge requests found
from flask import Flask, request, render_template
import os
from flask import Flask, request, Response
from multiprocessing import Process
from generate_html import generate_html
from utils import TOKEN, CLIENT_PORT, CLIENT_PATH
from utils import TOKEN, CLIENT_PORT, CLIENT_PATH, TEMPLATE_DIR
app = Flask(__name__)
@app.route(CLIENT_PATH)
def get_stat():
if request.args.get("token") != TOKEN:
return "Unauthorized", 401
return render_template("stat.html")
with open(os.path.join(TEMPLATE_DIR, "stat.html"), "r", encoding="utf-8") as f:
html = f.read()
return Response(html, mimetype="text/html")
if __name__ == "__main__":
p = Process(target=generate_html)
......
......@@ -48,7 +48,7 @@
<caption>Disk Stats:</caption>
<!-- <thead>
<tr>
<th>Partition</th>
<th>Part</th>
<th>Available (GB)</th>
<th>Usage</th>
</tr>
......@@ -60,13 +60,12 @@
<td>
<div class="usagebar">
<span style="width: {{disk['percent']}}%"></span>
<div>{{disk['free']}}</div>
<div>{{disk['free']}}GB</div>
</div>
</td>
<td>{{disk['percent']}}%</td>
</tr>
{% endfor %}
</tbody>
</table>
......
......@@ -48,7 +48,7 @@
<caption>Disk Stats:</caption>
<!-- <thead>
<tr>
<th>Partition</th>
<th>Part</th>
<th>Available (GB)</th>
<th>Usage</th>
</tr>
......@@ -60,13 +60,12 @@
<td>
<div class="usagebar">
<span style="width: {{disk['percent']}}%"></span>
<div>{{disk['free']}}</div>
<div>{{disk['free']}}GB</div>
</div>
</td>
<td>{{disk['percent']}}%</td>
</tr>
{% endfor %}
</tbody>
</table>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment