-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
38 lines (28 loc) · 909 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask, render_template, request
from pyecharts.charts import Bar
from statistics import Models
app = Flask(__name__, static_folder="templates")
def bar_base(modelId) -> Bar:
models = Models.select().where(Models.id == modelId).order_by(Models.timestamp.desc()).limit(8).execute()
xaxis = list()
yaxis = list()
for model in reversed(models):
y_title = model.name
yaxis.append(model.runCount + model.downloadCount)
xaxis.append(model.timestamp.strftime("%Y-%m-%d %H:%M:%S"))
c = (
Bar()
.add_xaxis(xaxis)
.add_yaxis(y_title, yaxis)
)
return c
@app.route("/")
def index():
return render_template("index.html")
@app.route("/barChart")
def get_bar_chart():
modelId = request.args.get('modelId')
c = bar_base(modelId)
return c.dump_options_with_quotes()
if __name__ == "__main__":
app.run()