License Detection Using Qrcode
License Detection Using Qrcode
P.SIRI CHANDANA
(2451-17-737-046)
MAHATHI REDDY
(2451-17-737-051)
M.AKHILA
(2451-7-737-063)
M.V.S.R ENGINEERING COLLEGE
(Affiliated to Osmania University, Hyderabad. Recognized by AICTE)
Nadergul, Saroornagar Mandal, Hyderabad-501510
CERTIFICATE
Certified that this a bonafide MiniProject work carried out by Mr./Ms. P.Sirichandana Bearing H.T. No.
2451-17-737-046 in the course MiniProject PW 333 IT prescribed for B.E( 3/4 ) Sem: V by Osmania
CERTIFICATE
Certified that this a bonafide MiniProject work carried out by Mr./Ms. V.Mahathi Bearing H.T. No.
2451-17-737-051 in the course MiniProject PW 333 IT prescribed for B.E( 3/4 ) Sem: V by Osmania
CERTIFICATE
Certified that this a bonafide MiniProject work carried out by Mr./Ms. M.Akhila
Bearing H.T. No. 2451-17-737-063 in the course MiniProject PW 333 IT prescribed for B.E( 3/4 ) Sem: V
by Osmania University, in the department during the academic year 2019 - 2020.
we proposed a system in which the work of traffic police and driver (user) is simplified. In this system the
driver will register to RTO services and the license will be issued to the user.The RTO officer will generate a
QR code attached to the license card for user .The QR code in the driving license can be used by the traffic
control authorities in case of a default. The QR code has all the details about you which can be seen via
scanner app which the traffic control authorities have. It has the details like your name,address, age, phone
number, fingerprint,digital sign,photo etc..
TABLE OF CONTENTS
S.NO. CONTENT PAGE.NO.
1 INTRODUCTION………………………………………………..1-5 1.1
PROBLEM OS STATEMENT
` 1.2 EXISTING SYSTEM
1.3 PROPOSED SYSTEM
1.4 SCOPE OF WORK
3 SYSTEM DESIGN………………………………………………9-20
3.1 SYSTEM ARCHITECTURE
3.2 DATAFLOW DIAGRAM
3.3 UML DIAGRAM
3.3.1 USE CASE DIAGRAM
3.3.2 CLASS DIAGRAM
3.3.3 SEQUENCE DIAGRAM
3.3.4 ACTIVITY DIAGRAM
3.4 SOFTWARE DEVELOPMENT
3.4.1 REQUIREMENTS
3.4.2 DESIGN
3.4.3 IMPLEMENTATION
3.4.4 TESTING
5 SELECTED SOFTWARE………………………………………22-29
5.1 PYTHON
5.2 PYTHON CONCEPTS
5.3 PYTHON LIBRARIES
5.4 PYTHON WEBFRAMEWORKS
5.5 PYTHON DATABASE COMMUNICATION
5.6 OPERATIONAL FEASIBILITY
6 TESTING……………………………………………………….30-34
6.1 SYSTEM TESTING
6.2 MODULE TESTING
6.3 INTEGRATION TESTING
6.4 ACCEPTANCE TESTING
7 SCREENSHOTS……………………………………………………35-38
8 CONCLUSION,……………………………………………………..39
9FUTURE ENHANCEMENTS………………………………………..40
11 SAMPLE CODE……………………………………………………43-49
CHAPTER-1
1. INTRODUCTION
In this project we have different modules in which they store different information and having different
service. In RTO it has process for registration of vehicle, their documents data all are stored in database in
which they access from here. They provide QR code foreach and every new license with respect to the age of
the customer .Now a days people who are below 18 are making the use of fake license by editing their details
with the original license details,this is the most offensive crime going in the cities and leads to accidents and
also violating traffic rules.Here comes the QR code provided on the license in to play,the traffic police
should have a scanner app so,that he can scan the QR code then immediately he will be able to see the details
of the user and make sure to match the both details,if the details are not matching then the user is using a
fake license and he will be charged and also gives them counsellling along with their parents.
1.1.PROBLEM OF STATEMENT:
This project develops a website which helps in simplifying the work of traffic police and the vehicle user.
Scanning QR code is easier than reading the smart chips .Many devices are available for scanning the QR
code through which traffic police can easily scan the license cards and find the fake users.
2
1.2.EXISTING SYSTEM:
License card with Smart Chip to scan this, a special device is required and also it is available only with some
traffic police officers.
3
1.3.PROPOSED SYSTEM:
License card with QR code which can be scanned using smart phone which is very easy so ,it can be detected
by anybody to reduce fake users.
4
1.4.SCOPE OF MINIPROJECT:
CHAPTER-2
2. TOOLS AND TECHNOLOGIES
2.1.LITERATURE SURVEY:
In this paper author surveyed problem of RTO, RTO employee having lot of work burden of making
registration ,license issue, transfer etc., which requires lots of paper work. As a result people cannot get
things done in right time this system helpful for RTO officials to maintain record systematically and reduces
lots of paper work and manual effort..In this paper, technique has been discussed for challan system. Here
user provide details to RTO database. by scanning QR code which contains overall information of the
vehicle we get vehicle owner details. This system also detect culprit vehicle. This paper introduces system
would make it easier for the public as it becomes an automated process. As the documents no need be
carried, it wouldn’t be misplaced and also misused. Hence for the safety of the documents. This system Make
one unique identity as a driver license.This system proposes, ”cross verification of driver and license for
RTO”, effectively verifies documents related to vehicle and license. This system introduces facility for RTO
officials to maintain records systematically and reduces lots of paper work and manual effort . In this paper,
we have designed a security system for QR codes. Since QR code security is essential and QR codes are
increasingly used in all fields, this system can protect users’ privacy and identity in addition to their smart
phone devices. Security system can detect attacks like: QR code
6
2.2. HARDWARE REQUIREMENTS:
The hardware requirement specifies each interface of the software elements and the hardware elements of the
system. These hardware requirements include configuration characteristics.
System : Pentium IV 2.4 GHz.
Hard Disk : 100 GB.
Monitor : 15 VGA Color.
Mouse : Logitech.
RAM : 1 GB.
The software requirements specify the use of all required software products like data management system.
The required software product specifies the numbers and version. Each interface specifies the purpose of the
interfacing software as related to this software product.
Database : Sqlite
CHAPTER-3
3.SYSTEM DESIGN
3.1.SYSTEM ARCHITECTURE:
The purpose of the design phase is to arrange an answer of the matter such as by the necessity document.
This part is that the opening moves in moving the matter domain to the answer domain. The design phase
satisfies the requirements of the system. The design of a system is probably the foremost crucial issue warm
heartedness the standard of the software package. It’s a serious impact on the later part, notably testing and
maintenance.
The output of this part is that the style of the document. This document is analogous to a blueprint of answer
and is employed later throughout implementation, testing and maintenance. The design activity is commonly
divided into 2 separate phases System Design and Detailed Design.
System Design conjointly referred to as top-ranking style aims to spot the modules that ought to be within
the system, the specifications of those modules, and the way them move with one another to supply the
specified results.
At the top of the system style all the main knowledge structures, file formats, output formats, and also the
major modules within the system and their specifications square measure set. System design is that the
method or art of process the design, components, modules, interfaces, and knowledge for a system to satisfy
such as needs. Users will read it because the application of systems theory to development.
Detailed Design, the inner logic of every of the modules laid out in system design is determined.
Throughout this part, the small print of the info of a module square measure sometimes laid out in a high-
level style description language that is freelance of the target language within which the software package
can eventually be enforced.
In system design the main target is on distinguishing the modules, whereas throughout careful style the main
target is on planning the logic for every of the modules.
9
Data Flow Diagram can also be termed as bubble chart. It is a pictorial or graphical form, which can be
applied to represent the input data to a system and multiple functions carried out on the data and the
generated output by the system.
A graphical tool accustomed describe and analyze the instant of knowledge through a system manual
or automatic together with the method, stores of knowledge, and delays within the system. The
transformation of knowledge from input to output, through processes, is also delineate logically and severally
of the physical elements related to the system. The DFD is also known as a data flow graph or a bubble
chart.The BasicNotation used to create a DFD’s are as follows:
Dataflow:
Process:
.
Source:
Data Store:
Rhombus: decision
10
3.3.UML DIAGRAMS:
The Unified Modeling Language allows the software engineer to express an analysis model using the
modeling notation that is governed by a set of syntactic semantic and pragmatic rules.
A UML system is represented using five different views that describe the system from distinctly different
perspective. Each view is defined by a set of diagram, which is as follows.
This view represents the system from the users perspective. The analysis representation describes a usage
scenario from the end-users perspective.
It represents the dynamic of behavioral as parts of the system, depicting the interactions of collection
between various structural elements described in the user model and structural model view.
In this the structural and behavioral as parts of the system are represented as they are to be built.
11
A use case diagram at its simplest is a representation of a user's interaction with the system and depicting the
specifications of a use case. A use case diagram can portray the different types of users of a system and the
various ways that they interact with the system. This type of diagram is typically used in conjunction with
the textual use case and will often be accompanied by other types of diagrams as well.
Figure 3.3.1 Use Case Diagram for system.
12
3.3.2.CLASS DIAGRAM:
The class diagram is the main building block of object oriented modeling. It is used both for general
conceptual modeling of the systematic of the application, and for detailed modeling translating the models
into programming code. Class diagrams can also be used for data modeling. The classes in a class diagram
represent both the main objects, interactions in the application and the classes to be programmed. A class
with three sections, in the diagram, classes is represented with boxes which contain three parts:
13
3.3.3.SEQUENCEDIAGRAM:
A sequence diagram is a kind of interaction diagram that shows how processes operate with one another and
in what order. It is a construct of a Message Sequence Chart. A sequence diagram shows object interactions
arranged in time sequence. It depicts the objects and classes involved in the scenario and the sequence of
messages exchanged between the objects needed to carry out the functionality of the scenario. Sequence
diagrams are typically associated with use case realizations in the Logical View of the system under
development. Sequence diagrams are sometimes called event diagrams, event scenarios, and timing
diagrams.
Figure 3.3.3: Sequence diagram for system
14
3.3.4 ACTIVITY DIAGRAM
Activity diagrams are graphical representations of workflows of stepwise activities and actions with support
for choice, iteration and concurrency. In the Unified Modeling Language, activity diagrams can be used to
describe the business and operational step-by-step workflows of components in a system. An activity
diagram shows the overall flow of control.
Figure 3.3.4: Activity DiagramFor System
15
3.4.SOFTWARE DEVELOPMENT:
There is various software development approaches defined and designed which are used/employed during
development process of software, these approaches are also referred as "Software Development Process
Models". Each process model follows a particular life cycle in order to ensure success in process of software
development.
16
3.4.1.REQUIREMENTS:
Business requirements are gathered in this phase. This phase is the main focus of the project managers and
stake holders. Meetings with managers, stake holders and users are held in order to determine the
requirements. Who is going to use the system? How will they use the system? What data should be input
into the system? What data should be output by the system? These are general questions that get answered
during a requirements gathering phase. This produces a nice big list of functionality that the system should
provide, which describes functions the system should perform, business logic that processes data, what data
is stored and used by the system, and how the user interface should work. The overall result is the system as
a whole and how it performs, not how it is actually going to do it.
17
3.4.2.DESIGN:
The software system design is produced from the results of the requirements phase. Architects have the ball
in their court during this phase and this is the phase in which their focus lies. This is where the details on
how the system will work is produced. Architecture, including hardware and software, communication,
software design (UML is produced here) are all part of the deliverables of a design phase.
18
3.4.3.IMPLEMENTATION:
Code is produced from the deliverables of the design phase during implementation, and this is the longest
phase of the software development life cycle. For a developer, this is the main focus of the life cycle because
this is where the code is produced. Implementation my overlap with both the design and testing phases.
Many tools exists (CASE tools) to actually automate the production of code using information gathered and
produced during the design phase.
19
3.4.4.TESTING:
During testing, the implementation is tested against the requirements to make sure that the product is actually
solving the needs addressed and gathered during the requirements phase. Unit tests and system/acceptance
tests are done during this phase. Unit tests act on a specific component of the system, while system tests act
on the system as a whole.
So in a nutshell, that is a very basic overview of the general software development life cycle model. Now
let’s delve into some of the traditional and widely used variations.
20
CHAPTER-4
The administrative user interface concentrates on the consistent information that is practically, part of
the organizational activities and which needs proper authentication for the data collection. The Interface
helps the administration with all the transactional states like data insertion, data deletion, and data updating
along with executive data search capabilities.
The operational and generic user interface helps the users upon the system in transactions through the
existing data and required services. The operational user interface also helps the ordinary users in managing
their own information helps the ordinary users in managing their own information in a customized manner as
per the assisted flexibilities.
21
CHAPTER-5
5. SOFTWARE
5.1.PYTHON
What is Python? Chances you are asking yourself this. You may have found this book because you want to
learn to program but don’t know anything about programming languages. Or you may have heard of
programming languages like C, C++, C#, or Java and want to know what Python is and how it compares to
“big name” languages. Hopefully I can explain it for you.
22
5.2.PYTHON CONCEPTS:
If you not interested in the how and whys of Python, feel free to skip to the next chapter. In this chapter I will
try to explain to the reader why I think Python is one of the best languages available and why it’s a great one
to start programming with.
• Open source general-purpose language.
• Object Oriented, Procedural, Functional
• Easy to interface with C/ObjC/Java/Fortran
• Easy-ish to interface with C++ (via SWIG)
• Great interactive environment
Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to
be highly readable. It uses English keywords frequently where as other languages use punctuation, and it
has fewer syntactical constructions than other languages.
Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to compile
your program before executing it. This is similar to PERL and PHP.
Python is Interactive − You can actually sit at a Python prompt and interact with the interpreter
directly to write your programs.
Python is a Beginner's Language − Python is a great language for the beginner-level programmers
and supports the development of a wide range of applications from simple text processing to WWW
browsers to games.
23
5.3 PYTHON LIBRARIES:
1. Requests. The most famous http library written by kenneth reitz. It’s a must have for every python
developer.
2. Scrapy. If you are involved in webscraping then this is a must have library for you. After using this library
you won’t use any other.
3. wxPython. A gui toolkit for python. I have primarily used it in place of tkinter. You will really love it.
4. Pillow. A friendly fork of PIL (Python Imaging Library). It is more user friendly than PIL and is a must
have for anyone who works with images.
5. SQLAlchemy. A database library. Many love it and many hate it. The choice is yours.
6. BeautifulSoup. I know it’s slow but this xml and html parsing library is very useful for beginners.
7. Twisted. The most important tool for any network application developer. It has a very beautiful api and is
used by a lot of famous python developers.
8. NumPy. How can we leave this very important library ? It provides some advance math functionalities to
python.
9. SciPy. When we talk about NumPy then we have to talk about scipy. It is a library of algorithms and
mathematical tools for python and has caused many scientists to switch from ruby to python.
10. matplotlib. A numerical plotting library. It is very useful for any data scientist or any data analyzer.
11. Pygame. Which developer does not like to play games and develop them ? This library will help you
achieve your goal of 2d game development.
12. Pyglet. A 3d animation and game creation engine. This is the engine in which the famous python port of
minecraft was made
13. pyQT. A GUI toolkit for python. It is my second choice after wxpython for developing GUI’s for my
python scripts.
14. pyGtk. Another python GUI library. It is the same library in which the famous Bittorrent client is created.
24
15. Scapy. A packet sniffer and analyzer for python made in python.
16. pywin32. A python library which provides some useful methods and classes for interacting with
windows.
17. nltk. Natural Language Toolkit – I realize most people won’t be using this one, but it’s generic enough. It
is a very useful library if you want to manipulate strings. But it’s capacity is beyond that. Do check it out.
18. nose. A testing framework for python. It is used by millions of python developers. It is a must have if you
do test driven development.
19. SymPy. SymPy can do algebraic evaluation, differentiation, expansion, complex numbers, etc. It is
contained in a pure Python distribution.
20. IPython. I just can’t stress enough how useful this tool is. It is a python prompt on steroids. It has
completion, history, shell capabilities, and a lot more. Make sure that you take a look at it.
25
A web framework is a code library that makes a developer's life easier when building reliable, scalable and
maintainable web applications.
Web frameworks encapsulate what developers have learned over the past twenty years while programming
sites and applications for the web. Frameworks make it easier to reuse code for common HTTP operations
and to structure projects so other developers with knowledge of the framework can quickly build and
maintain the application.
Frameworks provide functionality in their code or through extensions to perform common operations
required to run web applications. These common operations include:
1. URL routing
2. HTML, XML, JSON, and other output format templating
3. Database manipulation
4. Security against Cross-site request forgery (CSRF) and other attacks
5. Session storage and retrieval
Not all web frameworks include code for all of the above functionality. Frameworks fall on the spectrum
from executing a single use case to providing every known web framework feature to every developer. Some
frameworks take the "batteries-included" approach where everything possible comes bundled with the
framework while others have a minimal core package that is amenable to extensions provided by other
packages.
26
Connector/Python provides a connect() call used to establish connections to the MySQL server. The
following sections describe the permitted arguments for connect() and describe how to use option files
that supply additional arguments.
A database is an organized collection of data. The data are typically organized to model aspects of reality in a
way that supports processes requiring this information.
The term "database" can both refer to the data themselves or to the database management system. The
Database management system is a software application for the interaction between users database itself.
Databases are popular for many applications, especially for use with web applications or customer-oriented
programs
Users don't have to be human users. They can be other programs and applications as well. We will learn how
Python or better a Python program can interact as a user of an SQLdatabase.
The Python standard for database interfaces is the Python DB-API, which is used by Python's database
interfaces.
The DB-API has been defined as a common interface, which can be used to access relational databases.
In other words, the code in Python for communicating with a database should be the same, regardless of the
database and the database module used. Even though we use lots of SQL examples, this is not an
introduction into SQL but a tutorial on the Python interface.
SQLite is a simple relational database system, which saves its data in regular data files or even in the internal
memory of the computer, i.e. the RAM.
27
It was developed for embedded applications, like Mozilla-Firefox (Bookmarks), Symbian OS or Android.
SQLITE is "quite" fast, even though it uses a simple file. It can be used for large databases as well.
If you want to use SQLite, you have to import the module sqlite3. To use a database, you have to create first
a Connection object.
The connection object will represent the database. The argument of connection - in the following example
"companys.db" - functions both as the name of the file, where the data will be stored, and as the name of the
database. If a file with this name exists, it will be opened.
It has to be a SQLite database file of course! In the following example, we will open a database called
company.
MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is
compliant with the Python Database API Specification v2.0 (PEP 249). It is written in pure Python and does
not have any dependencies except for the Python Standard Library.
For notes detailing the changes in each release of Connector/Python, see MySQL Connector/Python Release
Notes.
28
5.6.OPERATIONAL FEASIBILITY:
User-friendly
Customer will use the forms for their various transactions i.e. for adding new routes, viewing the routes
details. Also the Customer wants the reports to view the various transactions based on the constraints. These
forms and reports are generated as user-friendly to the Client.
Reliability
The package wills pick-up current transactions on line. Regarding the old transactions, User will enter them
in to the system.
Security
The web server and database server should be protected from hacking, virus etc
Portability
The application will be developed using standard open source software (Except Oracle) like Java, tomcat
web server, Internet Explorer Browser etc these software will work both on Windows and Linux o/s. Hence
portability problems will not arise.
Availability
This software will be available always.
Maintainability
The system uses the 2-tier architecture. The 1st tier is the GUI, which is said to be front-end and the 2nd tier
is the database, which uses sqllite, which is the back-end.
The front-end can be run on different systems (clients). The database will be running at the server. Users
access these forms by using the user-ids and the passwords.
29
CHAPTER-6
6.TESTING
Testing is the process where the test data is prepared and is used for testing the modules individually and
later the validation given for the fields. Then the system testing takes place which makes sure that all
components of the system property functions as a unit. The test data should be chosen such that it passed
through all possible condition. The following is the description of the testing strategies, which were carried
out during the testing period.
30
31
To locate errors, each module is tested individually. This enables us to detect error and correct it without
affecting any other modules. Whenever the program is not satisfying the required function, it must be
corrected to get the required result. Thus all the modules are individually tested from bottom up starting with
the smallest and lowest modules and proceeding to the next level. Each module in the system is tested
separately. For example the job classification module is tested separately. This module is tested with different
job and its approximate execution time and the result of the test is compared with the results that are prepared
manually. Each module in the system is tested separately. In this system the resource classification and job
scheduling modules are tested separately and their corresponding results are obtained which reduces the
process waiting time.
32
After the module testing, the integration testing is applied. When linking the modules there may be chance
for errors to occur, these errors are corrected by using this testing. In this system all modules are connected
and tested. The testing results are very correct. Thus the mapping of jobs with resources is done correctly by
the system
33
34
CHAPTER-7
SCREENSHOTS
7.1. HOME PAGE
36
7.5 VIEW LIST PAGE
37
CHAPTER-8
8. CONCLUSION
Traffic police also have to just scan QR code to see the license and reduces fake users.
38
CHAPTER-9
9.FUTURE ENHANCEMENTS
It is not possible to develop a system that makes all the requirements of the user. User requirements keep
changing as the system is being used. Some of the future enhancements that can be done to this system are:
As the technology emerges, it is possible to upgrade the system and can be adaptable to desired
environment.
Based on the future security issues, security can be improved using emerging technologies like single
sign-on.
39
CHAPTER-10
10. REFERENCES AND BIBLIOGRAPHY
REFERENCES:
[1] Peter Mel and Tim Grace, "The NIST Definition of Cloud Computing", NIST, 2010.
[2]Achill Buhl, "Rising Security Challenges in Cloud Computing", in Proc. of World Congress on
Information and correspondence Technologies ,pp. 217-222, Dec. 2011.
[3]Srinivasarao D et al., "Breaking down the Superlative symmetric Cryptosystem Encryption Algorithm",
Journal of Global Research in Computer Science, vol. 7, Jul. 2011
[4] Tingyuan Nye and Tang Zhang "An investigation of DES and Blowfish encryption algorithm‟ , in Proc.
IEEE Region 10 Conference, pp. 1-4 ,Jan. 2009.
[5] Jitendra Singh Adam et al.," Modified RSA Public Key Cryptosystem Using Short Range Natural
Number Algorithm" , International Journal of Advanced Research in Computer Science and Software
Engineering ,vol. 2,Aug. 2012.
BIBLIOGRAPHY
python Technologies
python Script Programming by Yehuda Shiran
Mastering python Security
HTML
HTML Black Book by Holzner
sqllite
40
CHAPTER-11
PROJECT CODE
import os
import datetime
import pyqrcode
from io import BytesIO
from werkzeug.utils import secure_filename
app = Flask(__name__)
app.secret_key = os.urandom(24)
UPLOAD_FOLDER = 'C:\\Users\ADMIN\\Documents\\Python Project\\Licence
Detection Using QR Code\\static\\UploadImages'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@app.route("/")
def FUN_root():
return render_template("index.html")
@app.route("/index")
def index():
return render_template("index.html")
@app.route("/login")
def login():
return render_template("login.html")
@app.route("/ehome")
def ehome():
return render_template("ehome.html")
@app.route("/enterdatap")
def enterdatap():
return render_template("enterdata.html")
41
@app.route("/licence", methods = ['GET','POST'])
def licence():
id=request.args.get('id')
data3 = vlicence(id)
session['id'] = id
# data = qrcode(data3)
# print(data)
return render_template("licence.html",userdata=data3)
@app.route("/licences")
def licences():
data = vlicences()
return render_template("vlicences.html",userdata=data)
@app.route("/qrcode",methods = ['GET','POST'])
def qrcode():
# id=request.args.get('id')
id = session['id']
data3 = vlicence(id)
data = "Name: "+str(data3[0][1]) +"\n"+"Father's Name: "+ data3[0][2]
+"\n"+"Date Of Birth: "+ data3[0][3] +"\n"+"House No: "+ data3[0][4]
+"\n"+"Colony: "+ data3[0][5] +"\n"+"Location: "+ data3[0][6]
+"\n"+"Mandal: "+ data3[0][7] +"\n"+"District: "+ data3[0][8] +"\n"+"Pin:
"+ data3[0][9] +"\n"+"Date Of Issue: "+ data3[0][10] +"\n"+"Validity: "+
data3[0][11]
url = pyqrcode.create(data)
stream = BytesIO()
url.svg(stream, scale=1)
return stream.getvalue(), -12, {
'Content-Type': 'image/svg+xml',
'Expires': '0'}
# ------------------Add Data----------------------------
@app.route("/enterdata", methods=['GET', 'POST'])
def enter():
if request.method == 'POST':
f = request.files['photo']
g = request.files['usersign']
h = request.files['authoritysign']
photoname=secure_filename(f.filename)
signname=secure_filename(g.filename)
asignname=secure_filename(h.filename)
f.save(os.path.join(app.config['UPLOAD_FOLDER'], photoname))
42
g.save(os.path.join(app.config['UPLOAD_FOLDER'], signname))
h.save(os.path.join(app.config['UPLOAD_FOLDER'], asignname))
status = storedata(request.form['name'],
request.form['fname'],request.form['dob'],request.form['hno'],request.for
m['colony'],request.form['location'],request.form['mandal'],request.form[
'dist'],request.form['pin'],request.form['rta'],photoname,signname,asignn
ame,request.form['ref'],request.form['vtype'],request.form['badge'],reque
st.form['blood'])
if status == 1:
return render_template("enterdata.html", m1="sucess")
else:
return render_template("enterdata.html", m2="Failed")
else:
return render_template("enterdata.html")
# ----------------------------------------------------------------
@app.route("/loginact", methods=['GET', 'POST'])
def logact():
if request.method == 'POST':
else:
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True, host='127.0.0.1', port=5000)
DATABASE:
import datetime
import MySQLdb
from flask import session
from datetime import date
from datetime import timedelta
from datetime import datetime
43
def db_connect():
_conn = MySQLdb.connect(host="localhost", user='root',
password='root', db='qrcode')
c = _conn.cursor()
return c, _conn
# .........................Registration Action
Start....................................................................
..
def storedata(name, fname, dob, hno, colony, location, mandal, dist, pin,
rta, photo, usersign, authoritysign, ref, vtype, badge, bloodgroup):
try:
c, conn = db_connect()
print("hi")
today = date.today()
issue = today.strftime("%d/%m/%Y")
year = datetime.now()+timedelta(days=7300+5) # Added 20Years In
Current Date
val = year.strftime("%d/%m/%Y")
print(val)
j = c.execute("insert into userdata
(name,fname,dob,hno,colony,location,mandal,dist,pin,issue,validity,rta,ph
oto,usersign,authoritysign,ref,vtype,badge,bloodgroup) values
('"+name+"','"+fname+"','"+dob +
"','"+hno+"','"+colony+"','"+location+"','"+mandal+
"','"+dist+"','"+pin+"','"+issue+"','"+val+"','"+rta+"','"+photo+"','"+us
ersign+"','"+authoritysign+"','"+ref+"','"+vtype+"','"+badge+"','"+bloodg
roup+"')")
conn.commit()
conn.close()
return j
except Exception as e:
return(str(e))
# .........................Registration Action
End......................................................................
..
44
try:
c, conn = db_connect()
j = c.execute("select * from employee where username='" +
username+"' and password='"+password+"'")
conn.close()
return j
except Exception as e:
return(str(e))
# .........................View Action
Start....................................................................
..........
def vlicences():
c, conn = db_connect()
c.execute("select * from userdata")
result = c.fetchall()
conn.close()
return result
def vlicence(id):
c, conn = db_connect()
c.execute("select * from userdata where id='"+id+"'")
result = c.fetchall()
conn.close()
return result
# .........................View Action
End......................................................................
.........
if __name__ == "__main__":
print(db_connect())
connect to database:
SQLyog Community v13.1.2 (64 bit)
MySQL - 5.5.29 : Database – qrcode
45*******************************************************************
**
*/
USE `qrcode`;
46
CREATE TABLE `employee` (
`username` VARCHAR(100) DEFAULT NULL,
`password` VARCHAR(100) DEFAULT NULL
) ENGINE=INNODB DEFAULT CHARSET=latin1;
INSERT INTO
`userdata`(`id`,`name`,`fname`,`dob`,`hno`,`colony`,`location`,`mandal`,`dist`,`pin`,`is
sue`,`validity`,`rta`,`photo`,`usersign`,`authoritysign`,`ref`,`vtype`,`badge`,`bloodgrou
p`) VALUES
(9,'Shiva','K RAJU REDDY','2019-10-10','15-1/160','SAI SRINIVASA
NAGAR','DAMMAIGUDA','KEESARA','RANGA
REDDY','500038','28/10/2019','28/10/2039','RTA RANGAREDDY
EAST','a.jpg','a.jpg','a.jpg','654654','Light Motor Vehicle Non Transport','null','O+ve');