| from flask import Flask, render_template, send_file | |
| import pandas as pd | |
| app = Flask(__name__) | |
| # Load the CSV once at startup | |
| CSV_PATH = "contacts.csv" | |
| df = pd.read_csv(CSV_PATH) | |
| def home(): | |
| return render_template("table.html", tables=[df.to_html(classes="table table-bordered table-hover", index=False, border=0)], title="Contacts") | |
| def download(): | |
| return send_file(CSV_PATH, as_attachment=True) | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=7860) | |