diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2014-05-30 13:42:59 +0300 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2014-05-30 13:42:59 +0300 |
| commit | 7f9016aa0010325a4a06691d0b5a61b92d284cd0 (patch) | |
| tree | b6de791321ecf19d7d3b416b751b22ffa677305a /server.py | |
| parent | eb671b4075809b39071868e580276d0a842944ff (diff) | |
Fix data saving
Diffstat (limited to 'server.py')
| -rw-r--r-- | server.py | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1,8 +1,11 @@ +import json + +from datetime import datetime from flask import Flask from flask import render_template, request from unipath import FSPath as Path -DATA_DIR = Path(__file__).absolute().child('data') +DATA_DIR = Path(__file__).absolute().ancestor(1).child('data') app = Flask(__name__) @@ -15,7 +18,10 @@ def data(): if request.method == 'GET': return 'hai' elif request.method == 'POST': - print request.json + ts = datetime.now().strftime('%Y%m%d_%H%M%S') + for filename in ('data.json', 'data.{}.json'.format(ts)): + with open(DATA_DIR.child(filename), 'w') as f: + json.dump(request.json, f, indent=2) return 'ok' if __name__ == '__main__': |
