diff options
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__': |
