Netdeploy2 Babyyyy
This commit is contained in:
22
routes/clients.py
Normal file
22
routes/clients.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from flask import Blueprint, render_template, request, redirect, url_for
|
||||
from extensions import db
|
||||
from models.client import Client
|
||||
|
||||
bp = Blueprint("clients", __name__, url_prefix="/clients")
|
||||
|
||||
@bp.route("/")
|
||||
def list_clients():
|
||||
return render_template("clients/list.html", clients=Client.query.all())
|
||||
|
||||
@bp.route("/new", methods=["GET","POST"])
|
||||
def new_client():
|
||||
if request.method == "POST":
|
||||
c = Client(
|
||||
name=request.form["name"],
|
||||
email=request.form["email"]
|
||||
)
|
||||
db.session.add(c)
|
||||
db.session.commit()
|
||||
return redirect(url_for("clients.list_clients"))
|
||||
|
||||
return render_template("clients/new.html")
|
||||
Reference in New Issue
Block a user