diff --git a/anonkun.py b/anonkun.py index dc6dcb1..811b3d6 100644 --- a/anonkun.py +++ b/anonkun.py @@ -63,8 +63,11 @@ def text(data): """ Sent by a client when the user entered a new message. """ - message = data["msg"] - emit('message', {'msg': message}) + message = data["message"] + name = data["name"] + date = int(time.time()) + data["date"] = date + emit('message', data) @app.template_filter("strftime") @@ -72,7 +75,7 @@ def unix2string(unix): """ Converts a unix timestamp into a string. """ - form = "[%Y-%m-%d %H:%M:%S]" + form = "%Y-%m-%d %H:%M:%S" t = time.localtime(unix) return time.strftime(form, t) diff --git a/templates/index.html b/templates/index.html index 29143ee..9499a9c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,7 +5,6 @@
-

Lol

+

Chat

-
+
{% for message in messages %}
-
{{ message["name"] }} {{ message["date"] | strftime }}
+
+ {{ message["name"] }} {{ message["date"] | strftime }} +
{{ message["message"] }}
{% endfor %}