Flask/project_name/ext/webui/views.py
Simon Diesenreiter 5efd61d236
Some checks failed
CI / linter (ubuntu-latest, 3.9) (push) Failing after 1m29s
Rename the project from template / rename-project (push) Has been skipped
CI / tests_linux (ubuntu-latest, 3.9) (push) Has been skipped
initial commit
2024-11-10 07:27:36 -08:00

27 lines
628 B
Python

from flask import abort, render_template
from flask_simplelogin import login_required
from project_name.models import Product
def index():
products = Product.query.all()
return render_template("index.html", products=products)
def product(product_id):
product = Product.query.filter_by(id=product_id).first() or abort(
404, "produto nao encontrado"
)
return render_template("product.html", product=product)
@login_required
def secret():
return "This can be seen only if user is logged in"
@login_required(username="admin")
def only_admin():
return "only admin user can see this text"