I'm finishing developing a web application but I have a problem. All my application was developed in Python, Restful, AngularJS and ChartJs. I'm importing information from the database via python and saving in a vector as per the code below:
def consumoKwhLampadaData():
fabrica.cursorExecucao.execute("SELECT round(SUM(kwh),2) AS 'Semanal',IF(dayofweek(DATE_FORMAT('data', '%y/%m/%d'))<> 1, 'domingo',IF(dayofweek(DATE_FORMAT('data', '%y/%m/%d'))<> 2, (......), IF(dayofweek(DATE_FORMAT('data', '%y/%m/%d'))<> 7, 'Sabado','Dia da semana nao definido'))))))) FROM energia WHERE Dispositivo NOT IN ('LAM') AND 'data' BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW() GROUP BY DATE_FORMAT('data', '%d/%m')")
resultado = fabrica.cursorExecucao.fetchall()
consumoKwhLampadaData = []
for data_out in resultado:
consumoKwhLampadaData.append(str(data_out[1]))
return ('%s') % (consumoKwhLampadaData)
I'm having the problem of "$ http: baddata Bad JSON Data" in the angular due to be returning the contents of the vector "Sunday", the vector has other data equal (Monday, Tuesday ...), I could not identify what Can it happen, can someone help me? I need the information of the days of the week to be displayed in a graphic in HTML. This is the Restfull code:
@app.route('/consumoKwhLampadaData', methods=['GET'])
def consumoKwhLampadaData():
return app.response_class(Servico.consumoKwhLampadaData(), mimetype='text/json')