コード例 #1
0
def apidata_getdata():
    if request.method == 'POST' or request.method == 'GET':
        try:
            #jsonc.data_to_json(
            data = {
                'chart_data':
                json.loads(
                    jsonc.data_to_json(dynamodb.get_data_from_dynamodb())),
                'title':
                "IOT Data"
            }
            #data = data.replace("\"","'")
            print("before json loads")
            global counter
            global result_df

            # Convert to dataframe, dropping dynamoDB id column
            df = pd.DataFrame(data['chart_data'], dtype=float).drop(
                ['id', 'speedkmhour', 'datetime_value'], axis=1)
            result_df = ml.predict_danger(df)
            print('RESULT DF')
            print(result_df)

            #dataj = json.loads(data)
            print()
            print("after json loads")
            #print(dataj)
            #return data
            return jsonify(data)
            #return jsonify(data)

        except:
            import sys
            print(sys.exc_info()[0])
            print(sys.exc_info()[1])
コード例 #2
0
def apidata_getdata():
    if request.method == 'POST' or request.method == 'GET':
        try:
            #jsonc.data_to_json(
            data = {
                'chart_data':
                json.loads(
                    jsonc.data_to_json(dynamodb.get_data_from_dynamodb())),
                'title':
                "IOT Data"
            }
            #data = data.replace("\"","'")
            print("before json loads")
            print(data)
            #dataj = json.loads(data)
            print()
            print("after json loads")
            #print(dataj)
            #return data
            return jsonify(data)
            #return jsonify(data)

        except:
            import sys
            print(sys.exc_info()[0])
            print(sys.exc_info()[1])
コード例 #3
0
ファイル: server.py プロジェクト: zhaoyan543/McSausage
def apidata_getdata():
    if request.method == 'POST' or request.method == 'GET':
        try:
            data = {'chart_data': jsonc.data_to_json(dynamodb.get_data_from_dynamodb()), 
             'title': "IOT Data"}
            return jsonify(data)

        except:
            import sys
            print(sys.exc_info()[0])
            print(sys.exc_info()[1])
コード例 #4
0
ファイル: server.py プロジェクト: y2git/DISM-IOT-CA2
def apidata_getdata():
    if request.method == 'POST':
        try:
            data = {
                'chart_data':
                jsonc.data_to_json(dynamodb.get_data_from_dynamodb()),
                'lightnow': real_time(),
                'title': "IOT Data"
            }
            print(data)
            return jsonify(data)
        except:
            print("apidata_getdata error")
            print(sys.exc_info()[0])
            print(sys.exc_info()[1])
コード例 #5
0
def apidata_getdata():
    if request.method == 'POST' or request.method == 'GET':
        try:
            all_unique = dynamodb.get_all_unique()
            daily_unique_rfid = dynamodb.get_daily_urfid_dynamodb()
            data = {
                'ambient_data':
                jsonc.data_to_json(dynamodb.get_data_from_dynamodb()),
                'human_data':
                len(daily_unique_rfid)
            }
            counter = 1
            for i in all_unique:
                emp_data = jsonc.data_to_json(dynamodb.fetch_past_rfid(i))
                #wott = 'emp_data' + str(counter)
                data[i] = emp_data
                #counter = counter + 1
            return jsonify(data)

        except:
            import sys
            print(sys.exc_info()[0])
            print(sys.exc_info()[1])