Browse Source

Fix template path for client pages

main
def 2 weeks ago
parent
commit
8e9907eff2
  1. 12
      backend/app.py

12
backend/app.py

@ -1,7 +1,11 @@
from flask import Flask, render_template, request, redirect from flask import Flask, render_template, request, redirect
from db import get_db_connection from db import get_db_connection
app = Flask(__name__) app = Flask(
__name__,
template_folder="../templates",
static_folder="../static",
)
@app.route("/") @app.route("/")
def index(): def index():
@ -28,10 +32,8 @@ def dbtest():
def clients(): def clients():
conn = get_db_connection() conn = get_db_connection()
cursor = conn.cursor(dictionary=True) cursor = conn.cursor(dictionary=True)
cursor.execute("SELECT * FROM clients ORDER BY created_at DESC") cursor.execute("SELECT * FROM clients ORDER BY created_at DESC")
clients = cursor.fetchall() clients = cursor.fetchall()
conn.close() conn.close()
return render_template("clients/list.html", clients=clients) return render_template("clients/list.html", clients=clients)
@ -39,7 +41,6 @@ def clients():
@app.route("/clients/new", methods=["GET", "POST"]) @app.route("/clients/new", methods=["GET", "POST"])
def new_client(): def new_client():
if request.method == "POST": if request.method == "POST":
client_code = request.form["client_code"] client_code = request.form["client_code"]
company_name = request.form["company_name"] company_name = request.form["company_name"]
contact_name = request.form["contact_name"] contact_name = request.form["contact_name"]
@ -48,7 +49,6 @@ def new_client():
conn = get_db_connection() conn = get_db_connection()
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute( cursor.execute(
""" """
INSERT INTO clients INSERT INTO clients
@ -57,7 +57,6 @@ def new_client():
""", """,
(client_code, company_name, contact_name, email, phone) (client_code, company_name, contact_name, email, phone)
) )
conn.commit() conn.commit()
conn.close() conn.close()
@ -65,6 +64,5 @@ def new_client():
return render_template("clients/new.html") return render_template("clients/new.html")
if __name__ == "__main__": if __name__ == "__main__":
app.run(host="0.0.0.0", port=5050) app.run(host="0.0.0.0", port=5050)

Loading…
Cancel
Save