Spaces:
Runtime error
Runtime error
LearnwithShashank commited on
Commit ยท
c823597
1
Parent(s): d70a27d
5 unmodified lines67891011123 unmodified lines161718192021222324252627282930313233343536373839404142434445464748495051525354552 unmodified lines5859606162635 unmodified linesst.set_page_config(page_title="Expense Tracker", layout="wide")st.title("๐ธ Personal Expense Tracker")# Use secrets for API securityAPI_URL = st.secrets['API_URL']# Sidebar3 unmodified linesst.markdown("---")st.info("Track your daily expenses with ease.\nAll data is securely stored in Google Sheets.")# Main UIst.markdown("### โ๏ธ Log Your Expense")# Form layoutcol1, col2 = st.columns(2)with col1:date = st.date_input("Date", value=datetime.today())category = st.selectbox("Category", ["Food", "Transport", "Utilities", "Shopping", "Entertainment", "Other"])with col2:amount = st.number_input("Amount Spent (โน)", min_value=0.0, step=10.0, format="%.2f")# Quick amount presetsst.markdown("๐ก Quick Add:")preset_col1, preset_col2, preset_col3, preset_col4 = st.columns(4)if preset_col1.button("โน100"):amount = 100.0if preset_col2.button("โน200"):amount = 200.0if preset_col3.button("โน500"):amount = 500.0if preset_col4.button("โน1000"):amount = 1000.0notes = st.text_input("๐ Notes (optional)")# Submissionwith st.form("expense_form"):submitted = st.form_submit_button("๐ค Submit Expense")if submitted:payload = {"date": str(date),"category": category,"amount": str(amount),"notes": notes}2 unmodified linesres = requests.post(API_URL, data=payload)if res.status_code == 200 and "Success" in res.text:st.success("โ Expense added to Google Sheet successfully!")else:st.error("โ Failed to send data. Server says: " + res.text)except Exception as e:5 unmodified lines678910113 unmodified lines1516171819202122232425262728293031323334353637383940414243444546474849505152535455562 unmodified lines596061626364655 unmodified linesst.set_page_config(page_title="Expense Tracker", layout="wide")st.title("๐ธ Personal Expense Tracker")API_URL = st.secrets['API_URL']# Sidebar3 unmodified linesst.markdown("---")st.info("Track your daily expenses with ease.\nAll data is securely stored in Google Sheets.")# Initialize session state for amountif "quick_amount" not in st.session_state:st.session_state.quick_amount = 0.0st.markdown("### โ๏ธ Log Your Expense")with st.form("expense_form"):col1, col2 = st.columns(2)with col1:date = st.date_input("Date", value=datetime.today())category = st.selectbox("Category", ["Food", "Transport", "Utilities", "Shopping", "Entertainment", "Other"])with col2:amount = st.number_input("Amount Spent (โน)", min_value=0.0, step=10.0, format="%.2f", key="quick_amount")# Quick preset buttonsst.markdown("๐ก Quick Add:")quick_col1, quick_col2, quick_col3, quick_col4 = st.columns(4)if quick_col1.form_submit_button("โน100"):st.session_state.quick_amount = 100.0if quick_col2.form_submit_button("โน200"):st.session_state.quick_amount = 200.0if quick_col3.form_submit_button("โน500"):st.session_state.quick_amount = 500.0if quick_col4.form_submit_button("โน1000"):st.session_state.quick_amount = 1000.0notes = st.text_input("๐ Notes (optional)")submitted = st.form_submit_button("๐ค Submit Expense")if submitted:payload = {"date": str(date),"category": category,"amount": str(st.session_state.quick_amount),"notes": notes}2 unmodified linesres = requests.post(API_URL, data=payload)if res.status_code == 200 and "Success" in res.text:st.success("โ Expense added to Google Sheet successfully!")st.session_state.quick_amount = 0.0 # reset after successelse:st.error("โ Failed to send data. Server says: " + res.text)except Exception as e:
expense.py+26-24