File size: 1,188 Bytes
7ac4bca
2081f3a
7ac4bca
 
2081f3a
7ac4bca
2081f3a
7ac4bca
 
 
2081f3a
7ac4bca
 
 
53aafc3
7ac4bca
 
 
 
 
 
 
e8951e6
7ac4bca
 
e8951e6
7ac4bca
 
e8951e6
7ac4bca
 
 
 
 
9eca730
7ac4bca
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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)