backend/sweettweet/api.py
def api_updateGlucose():
    '''
    Get glucose data from request and return the glucose predictions 
    for the next 30 mins (6 timepoints).
    
    Also send an SMS alert if model predicts hypoglycemia in the next
    30 mins if user provides a phone number.
    '''

    # Extract data from request
    req_data = request.get_json()
    newBG = req_data['newBG']
    past_data = req_data['data']
    past_alarm = req_data['alarm']
    user_info = req_data['userInfo']


    # Update glucose data with new predictions and return alarm state
    data, alarm = app.model.forecast(past_data, user_info, newBG)

    # Decide whether to send an SMS alert or not
    sent_alarm = 0
    if alarm == 1 and past_alarm == 0:
        if user_info['phoneNumber']:
            send_alert(user_info['phoneNumber'])
            sent_alarm = 1

    # Return response with predicted data
    resp = jsonify({'data': json.loads(data),
                    'newBG' : '',
                    'userInfo' : user_info,
                    'alarm' : alarm,
                    'sent_alarm' : sent_alarm})

    print(resp)
    resp.status_code = 200

    return resp

    Get glucose data from request and return the glucose predictions 
    for the next 30 mins (6 timepoints).
    
    Also send an SMS alert if model predicts hypoglycemia in the next
    30 mins if user provides a phone number.
    
Get glucose data from request and return the glucose predictions
for the next 30 mins (6 timepoints).

Also send an SMS alert if model predicts hypoglycemia in the next
30 mins if user provides a phone number.
Get glucose data from request and return the glucose predictions for the next 30 mins ( 6 timepoints ) . Also send an SMS alert if model predicts hypoglycemia in the next 30 mins if user provides a phone number .
def api_updateGlucose():
    req_data = request.get_json()
    newBG = req_data['newBG']
    past_data = req_data['data']
    past_alarm = req_data['alarm']
    user_info = req_data['userInfo']
    data, alarm = app.model.forecast(past_data, user_info, newBG)
    sent_alarm = 0
    if alarm == 1 and past_alarm == 0:
        if user_info['phoneNumber']:
            send_alert(user_info['phoneNumber'])
            sent_alarm = 1
    resp = jsonify({'data': json.loads(data),
                    'newBG' : '',
                    'userInfo' : user_info,
                    'alarm' : alarm,
                    'sent_alarm' : sent_alarm})
    print(resp)
    resp.status_code = 200
    return resp
def api_updateGlucose ( ) : req_data = request . get_json ( ) newBG = req_data [ 'newBG' ] past_data = req_data [ 'data' ] past_alarm = req_data [ 'alarm' ] user_info = req_data [ 'userInfo' ] data , alarm = app . model . forecast ( past_data , user_info , newBG ) sent_alarm = 0 if alarm == 1 and past_alarm == 0 : if user_info [ 'phoneNumber' ] : send_alert ( user_info [ 'phoneNumber' ] ) sent_alarm = 1 resp = jsonify ( { 'data' : json . loads ( data ) , 'newBG' : '' , 'userInfo' : user_info , 'alarm' : alarm , 'sent_alarm' : sent_alarm } ) print ( resp ) resp . status_code = 200 return resp
Get glucose data from request and return the glucose predictions
for the next 30 mins (6 timepoints).
Get glucose data from request and return the glucose predictions for the next 30 mins ( 6 timepoints ) .
'''
    Get glucose data from request and return the glucose predictions 
    for the next 30 mins (6 timepoints).
    
    Also send an SMS alert if model predicts hypoglycemia in the next
    30 mins if user provides a phone number.
    ''' # Extract data from request # Update glucose data with new predictions and return alarm state # Decide whether to send an SMS alert or not # Return response with predicted data