Q: Step 1. You have been asked to add code in given template file “app.py” to enable login using employee table in test database. First Create Data Base: test Create table: employee Table fields: Id Int 10(primary key) auto increment username Varchar 25 Password Varchar 25 EmpMail Varchar 25  With 2 records 1 Manager Manager123 manager@gmail.com 2 Teller Teller123 teller@gmail.com Login should have username and password field. You are asked to add SQL code to get successful login.   Step 2. you should also add error message if credentials are wrong-Validation step   Step 3:  Add code to login .html template file to create Login form using text and password fields. Step 4. Add button to get sign-in action   Step 5: you should save the file in relevant locations to avoid path and output issues.   Step 6. You should have proper database connectivity to succeed in this lab worksheet. Successful connection to database also will be counted for marking.   Show your outputs through screenshots.       (app.py) file: # Store this code in 'app.py' file   from flask import Flask, render_template, request, redirect, url_for, session from flask_mysqldb import MySQL import MySQLdb.cursors import re     app = Flask(__name__) if __name__ == "__main__":     app.run(debug=True)     app.secret_key = 'your secret key'   app.config['MYSQL_HOST'] = 'localhost' app.config['MYSQL_USER'] = 'root' app.config['MYSQL_PASSWORD'] = '' app.config['MYSQL_DB'] = '' mysql = MySQL(app)   @app.route('/') @app.route('/login', methods =['GET', 'POST']) def login():     msg = ''     if request.method == 'POST' and 'username' in request.form and 'password' in request.form:         username = request.form['username']         password = request.form['password']         cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor)         cursor.execute('SELECT * FROM accounts WHERE username = % s AND password = % s', (username, password, ))         account = cursor.fetchone()         if account:                         msg = 'Logged in successfully !'             return render_template('index.html', msg = msg)         else:             msg = 'Incorrect username / password !'     return render_template('login.html', msg = msg)   photo dowen if u need them see

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Q:

Step 1. You have been asked to add code in given template file “app.py” to enable login using employee table in test database. First

Create Data Base: test

Create table: employee

Table fields:

Id

Int

10(primary key) auto increment

username

Varchar

25

Password

Varchar

25

EmpMail

Varchar

25

 With 2 records

1

Manager

Manager123

manager@gmail.com

2

Teller

Teller123

teller@gmail.com

Login should have username and password field. You are asked to add SQL code to get successful login.

 

Step 2. you should also add error message if credentials are wrong-Validation step

 

Step 3:  Add code to login .html template file to create Login form using text and password fields.

Step 4. Add button to get sign-in action

 

Step 5: you should save the file in relevant locations to avoid path and output issues.

 

Step 6. You should have proper database connectivity to succeed in this lab worksheet. Successful connection to database also will be counted for marking.

 

Show your outputs through screenshots.

 

 

 

(app.py) file:

# Store this code in 'app.py' file
 
from flask import Flask, render_template, request, redirect, url_for, session
from flask_mysqldb import MySQL
import MySQLdb.cursors
import re
 
 
app = Flask(__name__)
if __name__ == "__main__":
    app.run(debug=True)
 
 
app.secret_key = 'your secret key'
 
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = ''
app.config['MYSQL_DB'] = ''
mysql = MySQL(app)
 
@app.route('/')
@app.route('/login', methods =['GET', 'POST'])
def login():
    msg = ''
    if request.method == 'POST' and 'username' in request.form and 'password' in request.form:
        username = request.form['username']
        password = request.form['password']
        cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
        cursor.execute('SELECT * FROM accounts WHERE username = % s AND password = % s', (username, password, ))
        account = cursor.fetchone()
        if account:
           
            msg = 'Logged in successfully !'
            return render_template('index.html', msg = msg)
        else:
            msg = 'Incorrect username / password !'
    return render_template('login.html', msg = msg)

 

photo dowen if u need them see

Task Specification:
Step 1. You have been asked to add code in given template file "app.py" to enable login using
employee table in test database. First
Create Data Base: test
Create table: employee
Table fields:
Id
username
Password
EmpMail
With 2 records
1
2
Int
Varchar
Varchar
Varchar
Manager
Teller
10(primary key) auto increment
25
25
25
Manager123
Teller123
manager@gmail.com
teller@gmail.com
Login should have username and password field. You are asked to add SQL code to get
successful login.
Step 2. you should also add error message if credentials are wrong-Validation step
Step 3: Add code to login .html template file to create Login form using text and password
fields.
Step 4. Add button to get sign-in action
Step 5: you should save the file in relevant locations to avoid path and output issues.
Step 6. You should have proper database connectivity to succeed in this lab worksheet.
Successful connection to database also will be counted for marking.
Show your outputs through screenshots. (Ctrl) -
Transcribed Image Text:Task Specification: Step 1. You have been asked to add code in given template file "app.py" to enable login using employee table in test database. First Create Data Base: test Create table: employee Table fields: Id username Password EmpMail With 2 records 1 2 Int Varchar Varchar Varchar Manager Teller 10(primary key) auto increment 25 25 25 Manager123 Teller123 manager@gmail.com teller@gmail.com Login should have username and password field. You are asked to add SQL code to get successful login. Step 2. you should also add error message if credentials are wrong-Validation step Step 3: Add code to login .html template file to create Login form using text and password fields. Step 4. Add button to get sign-in action Step 5: you should save the file in relevant locations to avoid path and output issues. Step 6. You should have proper database connectivity to succeed in this lab worksheet. Successful connection to database also will be counted for marking. Show your outputs through screenshots. (Ctrl) -
mo/AppData/Local/Temp/Rar$EXa12340.29280/login.html
Login
{{ msg }}
Enter Your Username
Enter Your Password
mo/AppData/Local/Temp/Rar$EXa12340.27329/index.html
Sign In
Don't have an account? Sign Up here
Index
Hi
Welcome to the index page...
Logout
* Below line is used for online Google font */
@import
h2{
background-color: #FEFFED;
padding: 30px 35px;
margin: -10px -50px;
text-align:center;
border-radius: 10px 10px 0 0;
}
hr{
url(http://fonts.googlepis.com/css?family=Raleway);
margin: 10px -50px;
border: 0;
border-top: 1px solid
margin-bottom: 40px;
}
div.container {
width: 900px;
height: 610px;
margin:35px auto;
font-family: Raleway', sans-serif;
}
div.main{
width: 300px;
padding: 10px 50px 25px;
border: 2px solid gray;
border-radius: 10px;
font-family: raleway;
float:left;
margin-top: 50px;
}
input[type=text],input[type=password] {
width: 100%;
height: 40px;
padding: 5px;
margin-bottom: 25px;
margin-top: 5px;
border: 2px solid #ccc;
color: #4f4f4f;
#ccc;
S
label{
color: #464646;
text-shadow: 0 1px #fff;
font-size: 14px;
font-weight: bold;
}
center{
font-size: 32px;
}
.note{
color: red;
}
.valid{
color: green;
}
.back{
text-decoration: none;
border: 1px solid rgb(0, 143, 255);
rgb(0, 214, 255);
background-color:
padding: 3px 20px;
border-radius: 2px;
color: black;
}
input[type=button]{
font-size: 16px;
background: linear-gradient(#ffbc00 5%,#ffdd7f 100 %);
border: 1px solid #e5a900;
color: #4E4D4B;
font-weight: bold;
cursor: pointer;
width: 100%;
border-radius: 5px;
padding: 10px 0;
outline: none;
}
input[type=button]:hover{
background: linear-gradient( #ffdd7f 5%, #ffbc00 100%);
Transcribed Image Text:mo/AppData/Local/Temp/Rar$EXa12340.29280/login.html Login {{ msg }} Enter Your Username Enter Your Password mo/AppData/Local/Temp/Rar$EXa12340.27329/index.html Sign In Don't have an account? Sign Up here Index Hi Welcome to the index page... Logout * Below line is used for online Google font */ @import h2{ background-color: #FEFFED; padding: 30px 35px; margin: -10px -50px; text-align:center; border-radius: 10px 10px 0 0; } hr{ url(http://fonts.googlepis.com/css?family=Raleway); margin: 10px -50px; border: 0; border-top: 1px solid margin-bottom: 40px; } div.container { width: 900px; height: 610px; margin:35px auto; font-family: Raleway', sans-serif; } div.main{ width: 300px; padding: 10px 50px 25px; border: 2px solid gray; border-radius: 10px; font-family: raleway; float:left; margin-top: 50px; } input[type=text],input[type=password] { width: 100%; height: 40px; padding: 5px; margin-bottom: 25px; margin-top: 5px; border: 2px solid #ccc; color: #4f4f4f; #ccc; S label{ color: #464646; text-shadow: 0 1px #fff; font-size: 14px; font-weight: bold; } center{ font-size: 32px; } .note{ color: red; } .valid{ color: green; } .back{ text-decoration: none; border: 1px solid rgb(0, 143, 255); rgb(0, 214, 255); background-color: padding: 3px 20px; border-radius: 2px; color: black; } input[type=button]{ font-size: 16px; background: linear-gradient(#ffbc00 5%,#ffdd7f 100 %); border: 1px solid #e5a900; color: #4E4D4B; font-weight: bold; cursor: pointer; width: 100%; border-radius: 5px; padding: 10px 0; outline: none; } input[type=button]:hover{ background: linear-gradient( #ffdd7f 5%, #ffbc00 100%);
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education