|
|
|
|
@ -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,10 +32,8 @@ 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) |
|
|
|
|
@ -39,7 +41,6 @@ def clients():
|
|
|
|
|
@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,7 +49,6 @@ def new_client():
|
|
|
|
|
|
|
|
|
|
conn = get_db_connection() |
|
|
|
|
cursor = conn.cursor() |
|
|
|
|
|
|
|
|
|
cursor.execute( |
|
|
|
|
""" |
|
|
|
|
INSERT INTO clients |
|
|
|
|
@ -57,7 +57,6 @@ def new_client():
|
|
|
|
|
""", |
|
|
|
|
(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) |
|
|
|
|
|