-
Notifications
You must be signed in to change notification settings - Fork 1
/
handle_data.py
45 lines (36 loc) · 901 Bytes
/
handle_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 04 19:24:14 2017
@author: Sacha Perry-Fagant
"""
import sys
import cgi
import json
import flask
from flask import request, jsonify, render_template
import sys
import cgitb
cgitb.enable()
@app.route("/load_data", methods=["GET", "POST"])
def load_data():
values, zoom, flag, scheme = parse_data(request)
return json.dumps({'status':'OK'});
'''
sys.stdout.write("Content-Type: application/json")
sys.stdout.write("\n")
sys.stdout.write("\n")
form = cgi.FieldStorage()
data = json.dumps({ 'data': form.getvalue('x1')})
sys.stdout.write(data)
'''
def parse_data(data):
values = []
# There are 3 values per point
for i in range(1,6):
val = []
val.append(data['x'+str(i)])
val.append(data['y'+str(i)])
val.append(data['q'+str(i)])
values.append(val)
return values,
load_data()