-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsheety.py
46 lines (40 loc) · 1.51 KB
/
sheety.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import requests
import datetime
def sheet(number, name, mailid, age, gender, phone, tumorresponse, postprocess):
SHEETY_ENDPOINT = 'https://api.sheety.co/7d7181fff6979ab29d38349a22c8d851/deepTumorResponces/sheet1'
dt = datetime.datetime.now()
formatted_date = dt.strftime("%d/%m/%Y")
formatted_time = f"{dt.hour}:{dt.minute}:{dt.second}"
# Extract postprocess data
location = postprocess.get('location', 'N/A')
width_mm = postprocess.get('width', 'N/A')
height_mm = postprocess.get('height', 'N/A')
area_mm2 = postprocess.get('area', 'N/A')
# Handle non-numeric values
if width_mm != 'N/A':
width_mm = f"{width_mm:.2f} mm"
if height_mm != 'N/A':
height_mm = f"{height_mm:.2f} mm"
if area_mm2 != 'N/A':
area_mm2 = f"{area_mm2:.2f} mm²"
parameters_sheety = {
"sheet1": {
"timestamp": f"{formatted_date} {formatted_time}",
"id": number,
"name": name,
"mailid": mailid,
"age": age,
"gender": gender,
"phone": phone,
"tumorresponse": tumorresponse,
"tumorlength": width_mm,
"tumorwidth": height_mm,
"tumorarea": area_mm2,
"tumorlocation": location
}
}
# Post data to Sheety
response_sheet = requests.post(url=SHEETY_ENDPOINT, json=parameters_sheety)
print(response_sheet.status_code)
print(response_sheet.json())
print(response_sheet.text)