Question: this is my code from flask import Flask, render_template, url_for, flash, redirect from forms import RegistrationForm, LoginForm from werkzeug.security import generate_password_hash, check_password_hash import shelve app

this is my code

from flask import Flask, render_template, url_for, flash, redirect from forms import RegistrationForm, LoginForm from werkzeug.security import generate_password_hash, check_password_hash import shelve app = Flask(__name__, template_folder='template') app.app_context().push() app.config['SECRET_KEY'] = 'HELLO WORLD!' db = shelve.open("site.db", writeback=True) class User(object): def __init__(self, username, email, password): self.username = username self.email = email self.password = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password, password) @app.route("/home") def home(): return render_template('home.html') @app.route("/") def index(): return redirect(url_for('login')) @app.route("/register", methods=['GET', 'POST']) def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data, password=generate_password_hash(form.password.data)) if form.email.data in db: flash('Email already exists.', 'danger') return redirect(url_for('register')) db[form.email.data] = user flash('Your account has been created! You are now able to log in', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form) @app.route("/login", methods=['GET', 'POST']) def login(): form = LoginForm() if form.validate_on_submit(): if form.email.data in db: user = db[form.email.data] if check_password_hash(user.password, form.password.data): flash('You have been logged in!', 'success') return redirect(url_for('home')) flash('Login Unsuccessful. Please check email and password', 'danger') return render_template('login.html', title='Login', form=form) if __name__ == '__main__': app.run(port=4990) 

this is my RetrieveCustomer.html

{% extends "base.html" %} {% block title %}Library Loan System - Retrieve Customers{% endblock %} {% block content %} 

Retrieve Customers

{% if count == 0 %}

There are no customers.

{% elif count == 1 %}

There is 1 customer.

{% else %}

There are {{ count }} customers.

{% endif %}
{% for customer in customers_list %} {% endfor %}
User ID Customer ID First Name Last Name Gender Email Date Joined region Address
{{ customer.get_user_id() }} {{ customer.get_customer_id() }} {{ customer.get_first_name() }} {{ customer.get_last_name() }} {{ customer.get_gender() }} {{ customer.get_email() }} {{ customer.get_date_joined() }} {{ customer.get_region() }} {{ customer.get_address() }} Update

Delete Confirmation

Are you sure you want to delete {{customer.get_first_name()}} {{customer.get_last_name()}}?
{% endblock %}

1st problem: i want sort according to region like north, south , east and west and also sort customer based on date joined and also by male and female

2nd problem : i want to create retrieve statistics button in the retrieve customer and inside i want a data of how many customer leaving in each region and how many of them are male and female

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!