File size: 515 Bytes
7f48f0f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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)
@app.route("/")
def home():
return render_template("table.html", tables=[df.to_html(classes="table table-bordered table-hover", index=False, border=0)], title="Contacts")
@app.route("/download")
def download():
return send_file(CSV_PATH, as_attachment=True)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=7860)
|