From 8e9907eff2d6e91f710bd36b0e8855f2a02e6554 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 8 Mar 2026 07:21:22 +0000 Subject: [PATCH] Fix template path for client pages --- backend/app.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/backend/app.py b/backend/app.py index 54f1306..1319bbf 100644 --- a/backend/app.py +++ b/backend/app.py @@ -1,7 +1,11 @@ from flask import Flask, render_template, request, redirect from db import get_db_connection -app = Flask(__name__) +app = Flask( + __name__, + template_folder="../templates", + static_folder="../static", +) @app.route("/") def index(): @@ -28,18 +32,15 @@ def dbtest(): def clients(): conn = get_db_connection() cursor = conn.cursor(dictionary=True) - cursor.execute("SELECT * FROM clients ORDER BY created_at DESC") clients = cursor.fetchall() - conn.close() return render_template("clients/list.html", clients=clients) -@app.route("/clients/new", methods=["GET","POST"]) +@app.route("/clients/new", methods=["GET", "POST"]) def new_client(): if request.method == "POST": - client_code = request.form["client_code"] company_name = request.form["company_name"] contact_name = request.form["contact_name"] @@ -48,16 +49,14 @@ def new_client(): conn = get_db_connection() cursor = conn.cursor() - cursor.execute( """ INSERT INTO clients (client_code, company_name, contact_name, email, phone) - VALUES (%s,%s,%s,%s,%s) + VALUES (%s, %s, %s, %s, %s) """, (client_code, company_name, contact_name, email, phone) ) - conn.commit() conn.close() @@ -65,6 +64,5 @@ def new_client(): return render_template("clients/new.html") - if __name__ == "__main__": app.run(host="0.0.0.0", port=5050)