Added utils and updated unity version
This commit is contained in:
47
utils/server.py
Normal file
47
utils/server.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from flask import Flask, jsonify, request
|
||||
import json
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/cardboard')
|
||||
def card():
|
||||
data = json.load(open('/home/chris/dev/thesis/cardTrials.json'))
|
||||
return jsonify(data)
|
||||
|
||||
@app.route('/cardboardPost', methods=['POST'])
|
||||
def cardPost():
|
||||
id = int(request.args.get('id', ''))
|
||||
data = json.load(open('/home/chris/dev/thesis/cardTrials.json'))
|
||||
data['participantId'] = id
|
||||
json.dump(data,open('/home/chris/dev/thesis/cardTrials.json','w'))
|
||||
return 'ok ' + str(id)
|
||||
|
||||
|
||||
@app.route('/oculus')
|
||||
def oculus():
|
||||
data = json.load(open('/home/chris/dev/thesis/oculusTrials.json'))
|
||||
return jsonify(data)
|
||||
|
||||
@app.route('/oculusPost',methods=['POST'])
|
||||
def oculusPost():
|
||||
id = int(request.args.get('id', ''))
|
||||
data = json.load(open('/home/chris/dev/thesis/oculusTrials.json'))
|
||||
data['participantId'] = id
|
||||
json.dump(data,open('/home/chris/dev/thesis/oculusTrials.json','w'))
|
||||
return 'ok ' + str(id)
|
||||
|
||||
@app.route('/mouse')
|
||||
def mouse():
|
||||
data = json.load(open('/home/chris/dev/thesis/mouseTrials.json'))
|
||||
return jsonify(data)
|
||||
|
||||
@app.route('/mousePost',methods=['POST'])
|
||||
def mousePost():
|
||||
id = int(request.args.get('id', ''))
|
||||
data = json.load(open('/home/chris/dev/thesis/mouseTrials.json'))
|
||||
data['participantId'] = id
|
||||
json.dump(data,open('/home/chris/dev/thesis/mouseTrials.json','w'))
|
||||
return 'ok ' + str(id)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.debug = False
|
||||
app.run(host = '0.0.0.0',port=5000)
|
||||
Reference in New Issue
Block a user