From 6b30efcaa6352f85b6b82776522066fff6e303d8 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Fri, 30 May 2014 14:22:37 +0300 Subject: Initial load data --- server.py | 7 +++---- templates/home.html | 4 ++-- 2 files changed, 5 insertions(+), 6 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)): diff --git a/templates/home.html b/templates/home.html index 0d7b4f5..f3cf800 100644 --- a/templates/home.html +++ b/templates/home.html @@ -11,9 +11,9 @@