summaryrefslogtreecommitdiff
path: root/server.py
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2014-05-30 14:22:37 +0300
committerYuval Adam <yuv.adm@gmail.com>2014-05-30 14:22:37 +0300
commit6b30efcaa6352f85b6b82776522066fff6e303d8 (patch)
tree0cbb0c9cda218668ad0fc57829abed2458522e93 /server.py
parent214473c650918282ec4bceee883f3bcd86a1bc3d (diff)
Initial load data
Diffstat (limited to 'server.py')
-rw-r--r--server.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/server.py b/server.py
index e1129a8..227ba9a 100644
--- a/server.py
+++ b/server.py
@@ -1,8 +1,6 @@
-import json
-
from datetime import datetime
from flask import Flask
-from flask import render_template, request
+from flask import json, jsonify, render_template, request
from unipath import FSPath as Path
DATA_DIR = Path(__file__).absolute().ancestor(1).child('data')
@@ -16,7 +14,8 @@ def home():
@app.route('/data', methods=['POST', 'GET'])
def data():
if request.method == 'GET':
- return 'hai'
+ with open(DATA_DIR.child('data.json'), 'r') as f:
+ return jsonify(json.load(f))
elif request.method == 'POST':
ts = datetime.now().strftime('%Y%m%d_%H%M%S')
for filename in ('data.json', 'data.{}.json'.format(ts)):