2020-05-15 14:06:34 -04:00
|
|
|
from flask import Flask, jsonify, request
|
|
|
|
import json
|
2020-05-15 14:19:14 -04:00
|
|
|
import os
|
2020-05-15 14:06:34 -04:00
|
|
|
app = Flask(__name__)
|
|
|
|
|
2020-05-15 14:19:14 -04:00
|
|
|
base = os.getcwd()
|
|
|
|
|
2020-05-15 14:06:34 -04:00
|
|
|
@app.route('/cardboard')
|
|
|
|
def card():
|
2020-05-15 14:19:14 -04:00
|
|
|
data = json.load(open(base + '/cardTrials.json'))
|
2020-05-15 14:06:34 -04:00
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
@app.route('/cardboardPost', methods=['POST'])
|
|
|
|
def cardPost():
|
|
|
|
id = int(request.args.get('id', ''))
|
2020-05-15 14:19:14 -04:00
|
|
|
data = json.load(open(base + '/cardTrials.json'))
|
2020-05-15 14:06:34 -04:00
|
|
|
data['participantId'] = id
|
2020-05-15 14:19:14 -04:00
|
|
|
json.dump(data,open(base + '/cardTrials.json','w'))
|
2020-05-15 14:06:34 -04:00
|
|
|
return 'ok ' + str(id)
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/oculus')
|
|
|
|
def oculus():
|
2020-05-15 14:19:14 -04:00
|
|
|
data = json.load(open(base + '/oculusTrials.json'))
|
2020-05-15 14:06:34 -04:00
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
@app.route('/oculusPost',methods=['POST'])
|
|
|
|
def oculusPost():
|
|
|
|
id = int(request.args.get('id', ''))
|
2020-05-15 14:19:14 -04:00
|
|
|
data = json.load(open(base + '/oculusTrials.json'))
|
2020-05-15 14:06:34 -04:00
|
|
|
data['participantId'] = id
|
2020-05-15 14:19:14 -04:00
|
|
|
json.dump(data,open(base + '/oculusTrials.json','w'))
|
2020-05-15 14:06:34 -04:00
|
|
|
return 'ok ' + str(id)
|
|
|
|
|
|
|
|
@app.route('/mouse')
|
|
|
|
def mouse():
|
2020-05-15 14:19:14 -04:00
|
|
|
data = json.load(open(base + '/mouseTrials.json'))
|
2020-05-15 14:06:34 -04:00
|
|
|
return jsonify(data)
|
|
|
|
|
|
|
|
@app.route('/mousePost',methods=['POST'])
|
|
|
|
def mousePost():
|
|
|
|
id = int(request.args.get('id', ''))
|
2020-05-15 14:19:14 -04:00
|
|
|
data = json.load(open(base + '/mouseTrials.json'))
|
2020-05-15 14:06:34 -04:00
|
|
|
data['participantId'] = id
|
2020-05-15 14:19:14 -04:00
|
|
|
json.dump(data,open(base + '/mouseTrials.json','w'))
|
2020-05-15 14:06:34 -04:00
|
|
|
return 'ok ' + str(id)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app.debug = False
|
|
|
|
app.run(host = '0.0.0.0',port=5000)
|