Spaces:
No application file
No application file
Update App.py
Browse files1223356456878101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
import streamlit as stimport osimport json
# App Titlest.title("Notes Maker App")# App titlest.title("Streamlit User Interface Showcase")
# Sidebar# Sidebar for navigationst.sidebar.header("Navigation")options = ["Create Note", "View Notes"]choice = st.sidebar.radio("Select an option:", options)
# Directory to store notesNOTES_DIR = "notes"if not os.path.exists(NOTES_DIR): os.makedirs(NOTES_DIR)
# Function to save a notedef save_note(title, content): note_path = os.path.join(NOTES_DIR, f"{title}.json") with open(note_path, "w") as file: json.dump({"title": title, "content": content}, file) st.success(f"Note '{title}' saved successfully!")
# Function to load notesdef load_notes(): notes = [] for file_name in os.listdir(NOTES_DIR): with open(os.path.join(NOTES_DIR, file_name), "r") as file: note = json.load(file) notes.append(note) return notes
# Main App Logicif choice == "Create Note": st.header("Create a New Note") title = st.text_input("Note Title") content = st.text_area("Note Content")
if st.button("Save Note"): if title and content: save_note(title, content) else: st.error("Both title and content are required!")
elif choice == "View Notes": st.header("Your Notes") notes = load_notes() if notes: for note in notes: st.subheader(note["title"]) st.write(note["content"]) else: st.info("No notes found. Create your first note!")page = st.sidebar.radio("Go to", ["Home", "Widgets", "Layouts"])
# Home Pageif page == "Home": st.header("Welcome to the Streamlit UI Showcase!") st.write("This app demonstrates the use of various Streamlit components.") st.image( "https://docs.streamlit.io/logo.png", caption="Streamlit makes building apps easy!", use_column_width=True, )
# Widgets Pageelif page == "Widgets": st.header("Widgets in Streamlit")
st.subheader("Text Input") name = st.text_input("What's your name?") if name: st.write(f"Hello, {name}!")
st.subheader("Slider") age = st.slider("How old are you?", 0, 100, 25) st.write(f"You are {age} years old.")
st.subheader("Select Box") color = st.selectbox("What's your favorite color?", ["Red", "Blue", "Green"]) st.write(f"Your favorite color is {color}.")
st.subheader("Checkbox") agree = st.checkbox("I agree to the terms and conditions.") if agree: st.success("Thank you for agreeing!")
st.subheader("Button") if st.button("Click me"): st.balloons()
# Layouts Pageelif page == "Layouts": st.header("Layouts in Streamlit")
st.subheader("Columns") col1, col2, col3 = st.columns(3) col1.button("Column 1") col2.button("Column 2") col3.button("Column 3")
st.subheader("Tabs") tab1, tab2 = st.tabs(["Tab 1", "Tab 2"]) with tab1: st.write("This is Tab 1.") with tab2: st.write("This is Tab 2.")
st.subheader("Expander") with st.expander("See more"): st.write("This is additional information inside an expander.")
App.py+62-50