]> rtime.felk.cvut.cz Git - coffee/coffee-flask.git/blobdiff - app.py
Do not allow multiple reconnect timers running simultaneously
[coffee/coffee-flask.git] / app.py
diff --git a/app.py b/app.py
index f4fdc7f78eee249188b731f673a58fb2ad04a077..54816242b4640af21592d5c153f659a4ccadd3f1 100644 (file)
--- a/app.py
+++ b/app.py
@@ -76,7 +76,7 @@ def coffee_graph_flavors():
     fig = plt.figure(figsize=(3, 3))
     ax = fig.add_subplot(111)
     ax.set_aspect(1)
-    ax.pie(counts, autopct=lambda p: '{:.0f}'.format(p * sum(counts)/100))
+    ax.pie(counts, autopct=lambda p: '{:.0f}'.format(p * sum(counts)/100) if p != 0 else '')
     ax.legend(flavors, bbox_to_anchor=(1.0, 1.0))
     ax.set_title("Your taste")
     fig.savefig(b, format="svg", bbox_inches="tight")
@@ -145,8 +145,8 @@ def coffee_graph_history():
 def coffee_add():
     if request.method == "POST":
         json = request.json
-        if json and "uid" in session:
-            db.add_coffee(session["uid"], json["flavor"], json["time"])
+        print("User '%(uid)s' had '%(flavor)s' at %(time)s" % json)
+        db.add_coffee(json["uid"], json["flavor"], json["time"])
     return redirect(url_for('user'))
 
 
@@ -168,6 +168,6 @@ def js():
 def log():
     if request.method == "POST":
         data = request.data.decode("utf-8")
-        print(data)
+        print("Log:", data)
         return data
     return "nope"