tea / app.py
RP-Azul's picture
Update app.py
7ac4bca verified
# quicknote_app.py
import streamlit as st
import os
import json
st.set_page_config(page_title="QuickNote Clone", layout="wide")
# Load note ID from query parameter (optional)
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")
# Load existing note if available
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 editor
text_input = st.text_area("Your Note", value=note_text, height=500, label_visibility="collapsed")
# Save note manually
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!")
# Autosave every time user types (optional)
if text_input != note_text:
with open(note_file_path, "w", encoding="utf-8") as f:
json.dump({"text": text_input}, f)