|
|
|
|
|
import streamlit as st |
|
|
import os |
|
|
import json |
|
|
|
|
|
st.set_page_config(page_title="QuickNote Clone", layout="wide") |
|
|
|
|
|
|
|
|
query_params = st.experimental_get_query_params() |
|
|
note_id = query_params.get("note", ["default"])[0] |
|
|
|
|
|
NOTE_DIR = "notes" |
|
|
os.makedirs(NOTE_DIR, exist_ok=True) |
|
|
note_file_path = os.path.join(NOTE_DIR, f"{note_id}.json") |
|
|
|
|
|
|
|
|
if os.path.exists(note_file_path): |
|
|
with open(note_file_path, "r", encoding="utf-8") as f: |
|
|
note_data = json.load(f) |
|
|
note_text = note_data.get("text", "") |
|
|
else: |
|
|
note_text = "" |
|
|
|
|
|
st.title("π QuickNote Clone") |
|
|
st.caption("Clean text interface built with Streamlit.") |
|
|
|
|
|
|
|
|
text_input = st.text_area("Your Note", value=note_text, height=500, label_visibility="collapsed") |
|
|
|
|
|
|
|
|
if st.button("πΎ Save Note"): |
|
|
with open(note_file_path, "w", encoding="utf-8") as f: |
|
|
json.dump({"text": text_input}, f) |
|
|
st.success("Note saved!") |
|
|
|
|
|
|
|
|
if text_input != note_text: |
|
|
with open(note_file_path, "w", encoding="utf-8") as f: |
|
|
json.dump({"text": text_input}, f) |
|
|
|