Spaces:
Sleeping
Sleeping
nastasiasnk
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,24 @@ def test(input_json):
|
|
14 |
|
15 |
# Accessing the 'a_list' string and converting it to a list of integers
|
16 |
a_list = inputs['input']['a_list']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
#a_list = [int(item.strip()) for item in a_list_string.split(',')]
|
18 |
|
19 |
|
@@ -29,7 +47,8 @@ def test(input_json):
|
|
29 |
|
30 |
# Prepare the output
|
31 |
output = {
|
32 |
-
"
|
|
|
33 |
}
|
34 |
|
35 |
return json.dumps(output)
|
|
|
14 |
|
15 |
# Accessing the 'a_list' string and converting it to a list of integers
|
16 |
a_list = inputs['input']['a_list']
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
# Extract the datatree part which is a list of dictionaries
|
21 |
+
datatree = inputs["datatree"]
|
22 |
+
|
23 |
+
# Rebuild a Python dictionary from the datatree
|
24 |
+
# Initialize an empty dictionary
|
25 |
+
python_dict = {}
|
26 |
+
|
27 |
+
# Iterate through each item in the datatree list
|
28 |
+
for branch_dict in datatree:
|
29 |
+
# Each branch_dict is a dictionary with one key-value pair
|
30 |
+
for key, value in branch_dict.items():
|
31 |
+
# Assign the key and value to the new dictionary
|
32 |
+
python_dict[key] = value
|
33 |
+
|
34 |
+
|
35 |
#a_list = [int(item.strip()) for item in a_list_string.split(',')]
|
36 |
|
37 |
|
|
|
47 |
|
48 |
# Prepare the output
|
49 |
output = {
|
50 |
+
"list": a_list,
|
51 |
+
"matrix": python_dict,
|
52 |
}
|
53 |
|
54 |
return json.dumps(output)
|