Spaces:
Running
Running
adrianpierce
commited on
Commit
•
cb46f62
1
Parent(s):
b7d3916
Update pages/2_Saved_Recipes.py
Browse files- pages/2_Saved_Recipes.py +8 -3
pages/2_Saved_Recipes.py
CHANGED
@@ -6,18 +6,23 @@ st.title("Saved Recipes")
|
|
6 |
|
7 |
# get all saved files
|
8 |
directory_path = '/data/'
|
9 |
-
|
10 |
for root, dirs, files in os.walk(directory_path):
|
11 |
for file in files:
|
12 |
if file.endswith('.json'):
|
13 |
full_path = os.path.join(root, file)
|
14 |
f = open(full_path)
|
15 |
recipe_json = json.load(f)
|
16 |
-
|
17 |
|
18 |
#st.json(saved_files)
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
with st.expander(recipe['name']):
|
22 |
st.markdown(recipe['md'])
|
23 |
|
|
|
6 |
|
7 |
# get all saved files
|
8 |
directory_path = '/data/'
|
9 |
+
recipes = []
|
10 |
for root, dirs, files in os.walk(directory_path):
|
11 |
for file in files:
|
12 |
if file.endswith('.json'):
|
13 |
full_path = os.path.join(root, file)
|
14 |
f = open(full_path)
|
15 |
recipe_json = json.load(f)
|
16 |
+
recipes.append(recipe_json)
|
17 |
|
18 |
#st.json(saved_files)
|
19 |
|
20 |
+
user_search = st.text_input("Search Recipes", value="")
|
21 |
+
st.write("") # just some space
|
22 |
+
|
23 |
+
recipes_filtered = [x for x in recipes if user_search.lower() in x['name'].lower()]
|
24 |
+
|
25 |
+
for recipe in recipes_filtered:
|
26 |
with st.expander(recipe['name']):
|
27 |
st.markdown(recipe['md'])
|
28 |
|