Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications Dasfaa 2023 International Workshops Bdms 2023 Bdqm 2023 Gdma 2023 Bundlers 2023 Tianjin China April 17 20 2023 Proceedings Lncs 13922

Authors: Amr El Abbadi ,Gillian Dobbie ,Zhiyong Feng ,Lu Chen ,Xiaohui Tao ,Yingxia Shao ,Hongzhi Yin

1st Edition

3031354141, 978-3031354144

More Books

Students also viewed these Databases questions

Question

Solve the absolute value equation. |-10x| = -100

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago