-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflask-live-chart.py
57 lines (44 loc) · 1.76 KB
/
flask-live-chart.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
46
47
48
49
50
51
52
53
54
55
56
57
import json
from time import time
from random import random
from flask import Flask, render_template, make_response
import os
import pickle
#readFile = 'faceRecog/testfile' #format : [a, d, h, n, sad, sur, frame]
# //format : [weightedAvgProbs, weights, videoProbs, toneProbs, speechProbs, videoAttrs, toneAttrs, combinedEmotion]
# // size : [ 4 3 6 4 4 2 2 1 ]
app = Flask(__name__)
ROOT_INTERFACE = os.path.dirname(os.path.realpath(__file__))
readFile = os.path.join(ROOT_INTERFACE, 'picklesForInterface','pickleFile')
audioFile = os.path.join(ROOT_INTERFACE, 'picklesForInterface', 'audioPickleFile')
@app.route('/')
def renderHomePage():
return render_template('index.html', data = 'test')
@app.route('/videoPage')
def renderVideoPage():
return render_template('videoPage.html', data = 'test')
@app.route('/audioPage')
def renderAudioPage():
return render_template('audioPage.html', data = 'test')
@app.route('/textPage')
def renderTextPage():
return render_template('textPage.html', data = 'test')
#reads data from pipe file and sends to javaScript Highcharts
@app.route('/live-data')
def live_data():
with open(readFile, 'rb') as fp:
pickeDump = pickle.load(fp)
with open(audioFile, 'rb') as fp:
audioDump = pickle.load(fp)
#convert to single 1D array
receivedData = []
for array in pickeDump:
for element in array:
receivedData.append(element)
# for i in audioDump:
# receivedData.append(i)
response = make_response(json.dumps(receivedData))
response.content_type = 'application/json'
return response
# app.run(debug=True, host='127.0.0.1', port=5000)
app.run(debug=True, host='0.0.0.0', port=5000)