Exemplo n.º 1
0
def client(SEQUENCE):
    '''
    POST
    3초마다 post해주기: 20초짜리, 40초짜리, 80초짜리 이렇게.
    ==> 따라서 7번, 14번, 28번
    '''
    headers = {"Authorization": tokenEx.token_h("w3")}

    # wearerData/post

    for i in range(len(SEQUENCE)):
        data = dict()
        data['temp'], data['humid'], name = SEQUENCE[i]
        data['heartRate'] = "47"
        data['stepCount'] = "2000"

        response = requests.post(
            "http://ec2-3-34-84-225.ap-northeast-2.compute.amazonaws.com:8000/wearerData/post/",
            headers=headers,
            data=data)
        # print(data)

        print(name)
        print("Status Code:", response.status_code)
        response_data = response.json()
        print(response_data)
        time.sleep(3)
Exemplo n.º 2
0
def post_other(user, data):
    headers = {"Authorization": tokenEx.token_h(user)}

    # wearerData/post
    if type(data) == list:
        for d in data:
            print(d)
            response = requests.post(
                "http://ec2-3-34-84-225.ap-northeast-2.compute.amazonaws.com:8000/wearerData/post/",
                headers=headers,
                data=d)
            print("Status Code:", response.status_code)
            response_data = response.json()
            print(response_data)
            time.sleep(1)

    else:
        response = requests.post(
            "http://ec2-3-34-84-225.ap-northeast-2.compute.amazonaws.com:8000/wearerData/post/",
            headers=headers,
            data=data)

        print("Status Code:", response.status_code)
        response_data = response.json()
        print(response_data)
Exemplo n.º 3
0
def clientGetSensor(sensorUrl, namelist, prot, wear):
    headers = {"Authorization": tokenEx.token_h(prot)}
    for name in namelist:
        params = {"wearerID": tokenEx.wearerId(wear), "sensorName": name}
        response = requests.get(sensorUrl, headers=headers, params=params)
        print("Status Code:", response.status_code)
        response_data = response.json()
        pprint.pprint(response_data)
Exemplo n.º 4
0
def clientGetSensor(sensorUrl):
    headers = {"Authorization": tokenEx.token_h("p1")}

    params = {"wearerID": tokenEx.wearerId("w1")}
    response = requests.get(sensorUrl, headers=headers, params=params)
    print("Status Code:", response.status_code)
    response_data = response.json()
    pprint.pprint(response_data)
Exemplo n.º 5
0
def post_meter(user, data):
    headers = {"Authorization": tokenEx.token_h(user)}

    # wearerMeter/post/

    response = requests.post(
        "http://ec2-3-34-84-225.ap-northeast-2.compute.amazonaws.com:8000/wearerMeter/post/",
        headers=headers,
        data=data)

    print("Status Code:", response.status_code)
    response_data = response.json()
    print(response_data)
Exemplo n.º 6
0
def client_post():
    headers = {"Authorization": tokenEx.token_h("w1")}

    # wearerData/post

    data2 = {"latitude": "37.50423", "longitude": "127.0007899"}

    response = requests.post(
        "http://ec2-3-34-84-225.ap-northeast-2.compute.amazonaws.com:8000/wearerLocation/post/",
        headers=headers,
        data=data2)

    print("Status Code:", response.status_code)
    response_data = response.json()
    print(response_data)
Exemplo n.º 7
0
def client():
    headers = {"Authorization": tokenEx.token_h()}

    # linkedUsers/post

    data = {"wearer": "*****@*****.**", "protector": "*****@*****.**"}

    response = requests.post(
        "http://ec2-3-34-84-225.ap-northeast-2.compute.amazonaws.com:8000/linkedUser/post/",
        headers=headers,
        data=data)

    print("Status Code:", response.status_code)
    response_data = response.json()
    print(response_data)
Exemplo n.º 8
0
def client():
    headers = {"Authorization": tokenEx.token_h('abc')}

    # login
    credentials = {
        "username": "******",
        "fcm_token": "abc-token"
    }

    response = requests.put(
        "http://ec2-3-34-84-225.ap-northeast-2.compute.amazonaws.com:8000/user/changeFcmToken/", data=credentials, headers=headers)

    print("Status Code:", response.status_code)
    response_data = response.json()
    pprint.pprint(response_data)
Exemplo n.º 9
0
def client():
    headers = {"Authorization": tokenEx.token_h('w3')}

    # login
    credentials = {
        "username": "******",
        "email": "*****@*****.**",
        "password": "******"
    }

    response = requests.post(
        "http://ec2-3-34-84-225.ap-northeast-2.compute.amazonaws.com:8000/custom/login/",
        data=credentials)

    print("Status Code:", response.status_code)
    response_data = response.json()
    pprint.pprint(response_data)
Exemplo n.º 10
0
def client(uname):
    headers = {"Authorization": tokenEx.token_h(uname)}

    # wearerData/post

    data2 = {
        "fallEvent": "T",
        # T, F 중 하나
        "heartEvent": "N",
        "heatIllEvent": "N",
    }

    response = requests.post(
        "http://ec2-3-34-84-225.ap-northeast-2.compute.amazonaws.com:8000/wearerEvent/post/",
        headers=headers,
        data=data2)

    print("Status Code:", response.status_code)
    response_data = response.json()
    print(response_data)