summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-08-22 12:05:38 +0200
committerSanto Cariotti <sancn@live.com>2017-08-22 12:05:38 +0200
commit7e5c437b7c2b3f32ed4bd47aade921596ef5a6ee (patch)
tree86cfa6d17a2e2d437b9b980fae5d07d67a3c7567
parent6a76576558adc8cf15d7b44b59f0c1dc00c5b729 (diff)
fixed some things
-rw-r--r--lib/commands.py4
-rw-r--r--lib/web.py14
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/commands.py b/lib/commands.py
index ec44558..defdef6 100644
--- a/lib/commands.py
+++ b/lib/commands.py
@@ -20,7 +20,7 @@ class Commands(object):
self.user = cmd[2]
with open(co['path'], 'wb') as fout:
- fout.write(cmd[2].encode('utf-8'))
+ fout.write((cmd[2] + '\n').encode('utf-8'))
print('Ok')
elif cmd[1] is not ListCommands.commands['set']:
@@ -82,7 +82,7 @@ class Commands(object):
try:
with open(co['path'], 'ab') as fout:
- fout.write(('\n' + msg).encode('utf-8'))
+ fout.write((msg + '\n').encode('utf-8'))
print('Ok')
except:
diff --git a/lib/web.py b/lib/web.py
index 69522f8..bbad99d 100644
--- a/lib/web.py
+++ b/lib/web.py
@@ -1,11 +1,21 @@
from flask import Flask, render_template
-from .classes import r
+from .config import config
app = Flask(__name__)
@app.route("/")
def hello():
- lista = r.zrange('todo', 0, -1)
+ with open(config['path'], 'rb') as fout:
+ try:
+ lines = fout.readlines()
+ except:
+ lines = ''
+
+ if lines is not None:
+ lista = [x.strip() for i, x in enumerate(lines) if i > 0]
+ else:
+ lista = []
+
try:
return render_template("index.html", list_todo = lista, len_todo = len(lista))
except Exception as e: