# app.py
from flask import Flask, render_template, request, jsonify
import calendar
from datetime import datetime

app = Flask(__name__)
notes = {}  # Stores notes keyed by date string "YYYY-MM-DD"

@app.route('/')
def calendar_view():
    year = datetime.now().year
    month = datetime.now().month
    cal = calendar.monthcalendar(year, month)
    month_name = calendar.month_name[month]
    return render_template('calendar.html', year=year, month=month, month_name=month_name, cal=cal)

@app.route('/get_note', methods=['POST'])
def get_note():
    date_key = request.json.get('date')
    note = notes.get(date_key, "")
    return jsonify({'note': note})

@app.route('/save_note', methods=['POST'])
def save_note():
    date_key = request.json.get('date')
    note = request.json.get('note')
    notes[date_key] = note
    return jsonify({'status': 'success'})

if __name__ == '__main__':
    app.run(debug=True)

