import streamlit as st import json import os st.title("Saved Recipes") # get all saved files directory_path = '/data/' recipes = [] for root, dirs, files in os.walk(directory_path): for file in files: if file.endswith('.json'): full_path = os.path.join(root, file) f = open(full_path) recipe_json = json.load(f) recipes.append(recipe_json) #st.json(saved_files) user_search = st.text_input("Search Recipes", value="") st.write("") # just some space recipes_filtered = [x for x in recipes if user_search.lower() in x['name'].lower()] for recipe in recipes_filtered: with st.expander(recipe['name']): st.markdown(recipe['md']) # ignore # f = open('/data/test_output.json') # json_test = json.load(f) # st.json(json_test) # file_path = '/data/test_output.json' # if os.path.exists(file_path): # # Delete the file # os.remove(file_path) # st.write(f"The file {file_path} has been deleted.") # else: # st.write(f"The file {file_path} does not exist.")