@app.post('/save')
def save():
    headers = request.headers
    if (('X-API-KEY' not in headers) or (headers['X-API-KEY'] != config['api_key'])):
        sleep(5)
        return ('', 401)
    data = request.json
    dt = pd.Timestamp(data['dt'])
    (s_data, power) = rms(data['payload'], data['ticks'], dt)
    if (power < 0):
        logger.error(data)
        return ('', 204)
    if (power < 100):
        return str(power)
    rms_to_influx(power, dt)
    meas_to_influx(s_data)
    return str(power)
@app.post('/save')
def save():
    headers = request.headers
    if (('X-API-KEY' not in headers) or (headers['X-API-KEY'] != config['api_key'])):
        sleep(5)
        return (, 401)
    data = request.json
    dt = pd.Timestamp(data['dt'])
    (s_data, power) = rms(data['payload'], data['ticks'], dt)
    if (power < 0):
        logger.error(data)
        return (, 204)
    if (power < 100):
        return str(power)
    rms_to_influx(power, dt)
    meas_to_influx(s_data)
    return str(power)