master
Aevann1 2021-09-24 20:36:24 +02:00
parent 8aab42f4e1
commit ff28472c20
1 changed files with 9 additions and 2 deletions

View File

@ -1270,10 +1270,16 @@ def admin_nunuke_user(v):
return redirect(user.url)
@app.get("/chart")
@auth_required
def chart(v):
file = cached_chart()
return send_file(f"../{file}")
@cache.memoize(timeout=86400)
def cached_chart():
days = int(request.values.get("days", 25))
now = time.gmtime()
@ -1331,6 +1337,7 @@ def chart(v):
posts_chart.legend(loc='upper left', frameon=True)
comments_chart.legend(loc='upper left', frameon=True)
plt.savefig("chart.png")
file = "chart.png"
plt.savefig(file)
plt.clf()
return send_file("../chart.png")
return file