Answered step by step
Verified Expert Solution
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 %}{% endblock %}
{% for customer in customers_list %} User ID Customer ID First Name Last Name Gender Date Joined region Address {% endfor %} {{ 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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started