0% found this document useful (0 votes)
17 views28 pages

Training Report Arisha

Uploaded by

Aarchie Maggu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views28 pages

Training Report Arisha

Uploaded by

Aarchie Maggu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

ABSTRACT

During the 4-week training program, I gained comprehensive insights into the installation,
usage, and real-life applications of Python and its framework, Flask. The training covered
detailed aspects of Flask, providing a comprehensive foundation in its usage, equipping the
learner with the skills and knowledge necessary to tackle modern software development
challenges, and offering a deep understanding of Flask's functionalities and practical
implementations.

This report highlights the key learnings and experiences acquired during the training period,
shedding light on the significance of Python and Flask in modern software development. It is
designed as an illumination of the invaluable insights and experiences gathered during this
training. The report offers a curated compilation of the pivotal lessons assimilated,
underscoring their intrinsic importance within the larger landscape of contemporary software
development. By shedding light on the multifaceted dimensions of Flask, this report seeks to
underscore its role as a quintessential tool in the arsenal of any modern Python developer.

1 | Page
ACKNOWLEDGMENT

I extend my heartfelt gratitude to all individuals and entities who played a significant role in

making the training program on Python a truly enriching experience. I would like to express my

sincere appreciation to Auribises Technologies, whose expertise, guidance, and patient teaching

style were instrumental in shaping my understanding of these complex frameworks. Their

dedication to imparting knowledge and fostering a conducive learning environment was truly

invaluable.

I am thankful to GURU NANAK DEV ENGINEERING COLLEGE, LUDHIANA for

organizing and facilitating this training program, providing the platform for us to explore the

intricacies of Python. The resources and support extended by the institution were instrumental in

making this learning journey possible.

Last but not least, my appreciation goes out to my family, friends, and fellow participants for

their unwavering support and encouragement throughout this endeavor. This report is a

culmination of the knowledge, insights, and experiences gained during this training program, and

it wouldn't have been possible without the collective efforts of all those mentioned above.

2 | Page
ABOUT AURIBISES TECHNOLOGIES

Auribises Technologies is a learning platform created by Infosys, a global leader in consulting,

technology, and outsourcing services. Auribises Technologies is designed to provide individuals

with a wide range of online courses and learning resources, covering various topics related to

technology, business, and professional skills.

The platform aims to help learners acquire new skills, stay updated with industry trends, and

enhance their professional capabilities. It offers a diverse catalog of courses, including

programming languages, software development frameworks, data science, artificial intelligence,

cloud computing, and more.

One notable aspect of Auribises Technologies is its connection to industry experts and mentors.

Learners often have access to experienced professionals who can provide guidance, feedback,

and insights throughout the learning journey. This mentorship approach helps learners bridge the

gap between theoretical knowledge and practical application.

In summary, Auribises Technologies serves as a comprehensive learning platform that empowers

individuals to enhance their skills and knowledge in various domains, ultimately aiding their

personal and professional growth in a rapidly evolving technological landscape.

3 | Page
INDEX

CHAPTER 1 - INTRODUCTION

1.1 INTRODUCTION TO PYTHON………………………...7

1.2 INTRODUCTION TO FLASK…………………………..12

1.3 INTRODUCTION TO VETSAPP.....................................14

CHAPTER 2 – TRAINING WORK UNDERTAKEN

2.1 PROJECT CODE...............................................................15

CHAPTER 3 – RESULTS AND DISCUSSIONS


FIG 3.1 DATA OF CUSTOMERS ..………………..……..…..29

FIG 3.2 LOGIN PAGE…………………………………………29

FIG 3.3 REGISTRATION PAGE……………..………………..30

FIG 3.4 DATA OF PET…………..………………...…….…….30

4 | Page
1.1 INTRODUCTION TO PYTHON

Python is a high-level, interpreted programming language known for its simplicity and

versatility. Created by Guido van Rossum and first released in 1991, Python emphasizes

readability with its clean, easy-to-understand syntax, making it an excellent choice for both

beginners and experienced developers. It supports multiple programming paradigms, including

procedural, object-oriented, and functional programming. Python’s extensive standard library

and rich ecosystem of third-party packages allow it to be used in various domains, from web

development and data analysis to artificial intelligence and machine learning. Its flexibility,

combined with a strong community, has made Python one of the most popular languages in the

world.

5 | Page
1.1.1 DATA TYPES

Python offers a rich set of built-in data types that cater to a wide variety of programming needs,

making it a flexible and powerful language for handling different forms of data. At the core,

Python supports basic data types such as integers (int), which represent whole numbers, and

floating-point numbers (float), used for decimal or fractional numbers. For working with text,

Python provides the string (str) data type, which allows developers to manipulate sequences of

characters. Strings are immutable, meaning their values cannot be changed after they are

created, promoting efficiency in memory use.

In addition to these basic types, Python has booleans (bool), which store True or False values,

often used in conditional logic. Moving beyond the simple types, Python introduces more

complex structures for storing collections of data. Lists are ordered and mutable, meaning their

contents can be modified, making them highly versatile for dynamic data storage. For example,

you can append, remove, or alter list elements easily during runtime. In contrast, tuples are also

ordered but immutable, making them useful when the collection's integrity should remain

unchanged.

Python also includes dictionaries (dict), which store data in key-value pairs, enabling efficient

retrieval of information based on a unique key. This data type is extremely useful for structured

data, such as when mapping names to addresses or storing configurations. Another important

data type is the set, an unordered collection of unique items, ideal for membership testing and

eliminating duplicates from a sequence.

Python’s dynamic typing system adds another layer of flexibility, allowing variables to change

their data type as needed during program execution without any explicit declaration. For

example, a variable can start as an integer, then later be assigned a string, and Python will

6 | Page
adjust accordingly. The language also offers special types such as None to represent null values

and custom types created through classes for object-oriented programming.

Altogether, Python's comprehensive set of data types supports everything from simple

arithmetic operations to sophisticated data handling in fields like machine learning, data

analysis, and web development. These data types are integral to Python's reputation as an

accessible yet powerful language, making it a favorite for both beginner programmers and

experts alike.

7 | Page
1.1.2 PRECEDENCE AND ASSOCIATIVITY

In Python, precedence and associativity are important rules that determine the order in which

operations are performed in expressions involving multiple operators. Precedence refers to the

priority of operators, dictating which operators are evaluated first. For example, multiplication

and division have higher precedence than addition and subtraction, so in an expression like 2 +

3 * 4, multiplication is performed first, resulting in 2 + 12 = 14. Associativity, on the other

hand, defines the direction in which operators of the same precedence are evaluated. Most

operators in Python, such as +, -, *, and /, have left-to-right associativity, meaning that they

are evaluated from left to right when they appear together in an expression. However, some

operators, like exponentiation **, follow right-to-left associativity, meaning an expression like

2 ** 3 ** 2 is evaluated as 2 ** (3 ** 2), yielding 512.

By understanding both precedence and associativity, developers can predict the order of

operations and ensure that their code produces the desired results without relying heavily on

parentheses to clarify the intended evaluation. When necessary, parentheses can be used to

override the default precedence and associativity, giving the programmer more control over

how expressions are calculated. These rules are fundamental in avoiding mistakes and writing

clear, efficient code in Python.

8 | Page
1.1.3 INPUT/OUTPUT

In Python, input and output operations are fundamental for user interaction and data processing.

The input() function is used to receive input from the user, capturing their responses as strings,

regardless of the type of data entered. To convert this input into other data types, such as integers

or floats, you can utilize type conversion functions like int() or float(). For example, using

input("Enter your age: ") allows the user to provide their age, which can then be converted to an

integer with int(). On the output side, Python employs the print() function to display information

to the console. This function can print strings, variables, or formatted strings, allowing for

multiple arguments to be displayed in a single call. Python also supports advanced string

formatting using f-strings, which enable seamless integration of variables within strings. For

instance, print(f"Your name is {name} and you are {age} years old.") efficiently outputs the

user's name and age in a single formatted message. Together, the input() and print() functions

facilitate straightforward communication between the program and the user, enhancing the

overall interactivity of Python applications.

9 | Page
1.2 INTRODUCTION TO FLASK

Flask is a lightweight and flexible web framework for Python, designed to facilitate the

rapid development of web applications. Created by Armin Ronacher and first released in

2010, Flask follows a minimalist approach, providing the essential tools needed to build

web applications while allowing developers the freedom to choose additional libraries and

tools as necessary. This makes Flask an excellent choice for both small projects and larger

applications that require customization.

One of the key features of Flask is its simplicity and ease of use. The framework is built on

the WSGI (Web Server Gateway Interface) toolkit and Jinja2 templating engine, allowing

developers to create dynamic web pages efficiently. Flask’s routing system enables

developers to define URL endpoints easily, making it straightforward to map different

URLs to corresponding functions in the application. Additionally, Flask supports various

HTTP methods, such as GET, POST, PUT, and DELETE, providing flexibility in handling

client requests.

Flask is also known for its extensibility. A wide range of extensions are available, enabling

features such as form validation, user authentication, database integration, and more. This

modular approach allows developers to choose only the components they need, keeping

applications lightweight and maintainable. Flask’s built-in development server and

debugger make the development process smoother, allowing for quick testing and

debugging.

Moreover, Flask is compatible with various databases through Object Relational Mapping

(ORM) libraries, such as SQLAlchemy, enabling easy data manipulation. Its support for

10 | Page
RESTful request dispatching makes it suitable for building RESTful APIs, allowing for

seamless communication between the frontend and backend.

Overall, Flask’s simplicity, flexibility, and rich ecosystem make it a popular choice among

developers for creating web applications, ranging from simple prototypes to complex

enterprise solutions. Its strong community support ensures that developers can easily find

resources, tutorials, and third-party libraries to enhance their projects, solidifying Flask's

position as one of the leading web frameworks in the Python ecosystem.

11 | Page
Chapter 1 : INTRODUCTION

VetsApp: A Digital Platform for Veterinary Services

This report provides a comprehensive overview of VetsApp, an innovative digital

platform designed to enhance accessibility and efficiency in veterinary care. The

report examines the platform’s objectives, features, user interface, impact on the

veterinary ecosystem, and future prospects. Additionally, it highlights the

challenges encountered during its implementation and provides recommendations

for continuous improvement.

Impact and Benefits

• For Pet Owners:

o Convenient access to expert veterinary care from home.

o Timely reminders reduce missed vaccinations or treatments.

o Emergency care becomes more accessible, minimizing wait times.

• For Veterinarians:

o Efficient management of appointments and patient records.

o Expanded client base through virtual consultations.

o Ability to manage follow-ups remotely, reducing clinic burden.

• For the Animal Care Ecosystem:

o Improved tracking of pet health trends and vaccination coverage.

o Encourages responsible pet ownership with access to educational resources.

o Collaboration opportunities between veterinarians, suppliers, and pet owners.

12 | Page
Chapter 2 - TRAINING WORK UNDERTAKEN
Code:

from flask import *

import datetime

from session18b import MongoDBHelper

import hashlib

from bson.objectid import ObjectId

web_app = Flask("Vets App")

@web_app.route("/")

def index():

return render_template("index.html")

@web_app.route("/register")

def register():

return render_template("register.html")

@web_app.route("/home")

def home():

return render_template("home.html", email=session["vet_email"])

@web_app.route("/register-vet", methods=["POST"])

def register_vet():

vet_data = {

"name": request.form["name"],

"email": request.form["email"],

"password": hashlib.sha256(request.form["pswd"].encode("utf-8")).hexdigest(),

"createdOn": datetime.datetime.today(),

print(vet_data)

13 | Page
db = MongoDBHelper(collection="vets")

# Update MongoDB Helper insert function, to return result here

result = db.insert(vet_data)

# Test the same

vet_id = result.inserted_id

session["vet_id"] = str(vet_id)

session["vet_name"] = vet_data["name"]

session["vet_email"] = vet_data["email"]

return render_template("home.html", email=session["vet_email"])

@web_app.route("/add-customer", methods=["POST"])

def add_customer():

# if len(session['vet_id']) == 0:

# return redirect("/")

customer_data = {

"name": request.form["name"],

"phone": request.form["phone"],

"email": request.form["email"],

"age": int(request.form["age"]),

"gender": request.form["gender"],

"address": request.form["address"],

"vet_id": session["vet_id"],

"vet_email": session["vet_email"],

"createdOn": datetime.datetime.today(),

if (

len(customer_data["name"]) == 0

or len(customer_data["phone"]) == 0

14 | Page
or len(customer_data["email"]) == 0

):

return render_template(

"error.html", message="Name, Phone and Email cannot be Empty"

print(customer_data)

db = MongoDBHelper(collection="customer")

db.insert(customer_data)

return render_template(

"success.html", message="{} added successfully".format(customer_data["name"])

@web_app.route("/update-customer-db", methods=["POST"])

def update_customer_in_db():

# if len(session['vet_id']) == 0:

# return redirect("/")

customer_data_to_update = {

"name": request.form["name"],

"phone": request.form["phone"],

"email": request.form["email"],

"age": int(request.form["age"]),

"gender": request.form["gender"],

"address": request.form["address"],

if (

len(customer_data_to_update["name"]) == 0

or len(customer_data_to_update["phone"]) == 0

or len(customer_data_to_update["email"]) == 0

15 | Page
):

return render_template(

"error.html", message="Name, Phone and Email cannot be Empty"

print(customer_data_to_update)

db = MongoDBHelper(collection="customer")

query = {"_id": ObjectId(request.form["cid"])}

db.update(customer_data_to_update, query)

return render_template(

"success.html",

message="{} updated successfully".format(customer_data_to_update["name"]),

@web_app.route("/login-vet", methods=["POST"])

def login_vet():

vet_data = {

"email": request.form["email"],

"password": hashlib.sha256(request.form["pswd"].encode("utf-8")).hexdigest(),

print(vet_data)

db = MongoDBHelper(collection="vets")

documents = db.fetch(vet_data)

print(documents, type(documents))

if len(documents) == 1:

session["vet_id"] = str(documents[0]["_id"])

session["vet_email"] = documents[0]["email"]

session["vet_name"] = documents[0]["name"]

print(vars(session))

16 | Page
return render_template(

"home.html", email=session["vet_email"], name=session["vet_name"]

else:

return render_template("error.html")

@web_app.route("/logout")

def logout():

session["vet_id"] = ""

session["vet_email"] = ""

return redirect("/")

@web_app.route("/fetch-customers")

def fetch_customers_of_vet():

db = MongoDBHelper(collection="customer")

# query = {'vet_email': session['vet_email']}

query = {"vet_id": session["vet_id"]}

documents = db.fetch(query)

print(documents, type(documents))

# return "Customers Fetched for the Vet {}".format(session['vet_name'])

return render_template(

"customers.html",

email=session["vet_email"],

name=session["vet_name"],

documents=documents,

@web_app.route("/fetch-all-pets")

def fetch_all_pets():

db = MongoDBHelper(collection="pet")

17 | Page
query = {"vet_id": session["vet_id"]}

documents = db.fetch(query)

print(documents, type(documents))

# return "Customers Fetched for the Vet {}".format(session['vet_name'])

return render_template(

"all-pets.html",

email=session["vet_email"],

name=session["vet_name"],

documents=documents,

@web_app.route("/fetch-pets/<id>")

def fetch_pets_of_customer(id):

db = MongoDBHelper(collection="customer")

query = {"_id": ObjectId(id)}

customer = db.fetch(query)[0]

db = MongoDBHelper(collection="pet")

query = {"vet_id": session["vet_id"], "customer_id": id}

documents = db.fetch(query)

print(documents, type(documents))

# return "Customers Fetched for the Vet {}".format(session['vet_name'])

return render_template(

"pets.html",

email=session["vet_email"],

name=session["vet_name"],

customer=customer,

documents=documents,

18 | Page
@web_app.route("/fetch-all-consultations")

def fetch_all_consultations():

db = MongoDBHelper(collection="consultation")

query = {"vet_id": session["vet_id"]}

documents = db.fetch(query)

print(documents, type(documents))

# return "Customers Fetched for the Vet {}".format(session['vet_name'])

return render_template(

"all-consultations-pets.html",

email=session["vet_email"],

name=session["vet_name"],

documents=documents,

@web_app.route("/fetch-consultation-customer-pets/<id>")

def fetch_consultations_of_customer_pets(id):

db = MongoDBHelper(collection="pet")

query = {"_id": ObjectId(id)}

pet = db.fetch(query)[0]

db = MongoDBHelper(collection="consultation")

query = {

"vet_id": session["vet_id"],

"customer_id": pet["customer_id"],

"pet_id": str(pet["_id"]),

print("[DEBUG] QUERY:", query)

documents = db.fetch(query)

print(documents, type(documents))

19 | Page
# return "Customers Fetched for the Vet {}".format(session['vet_name'])

return render_template(

"consultations-pets.html",

email=session["vet_email"],

name=session["vet_name"],

pet=pet,

documents=documents,

@web_app.route("/delete-customer/<id>")

def delete_customer(id):

db = MongoDBHelper(collection="customer")

query = {"_id": ObjectId(id)}

customer = db.fetch(query)[0]

db.delete(query)

return render_template(

"success.html", message="Customer {} Deleted".format(customer["name"])

@web_app.route("/update-customer/<id>")

def update_customer(id):

db = MongoDBHelper(collection="customer")

query = {"_id": ObjectId(id)}

customer = db.fetch(query)[0]

return render_template(

"update-customer.html",

email=session["vet_email"],

name=session["vet_name"],

customer=customer,

20 | Page
)

@web_app.route("/search")

def search():

return render_template(

"search.html", email=session["vet_email"], name=session["vet_name"]

@web_app.route("/add-pet/<id>")

def add_pet(id):

db = MongoDBHelper(collection="customer")

# To fetch customer where email and vet id will match

query = {"_id": ObjectId(id)}

customers = db.fetch(query)

customer = customers[0]

return render_template(

"add-pet.html",

vet_id=session["vet_id"],

email=session["vet_email"],

name=session["vet_name"],

customer=customer,

@web_app.route("/save-pet", methods=["POST"])

def save_pet():

pet_data = {

"name": request.form["name"],

"breed": request.form["breed"],

"age": int(request.form["age"]),

"gender": request.form["gender"],

21 | Page
"customer_id": request.form["customer_id"],

"customer_email": request.form["customer_email"],

"vet_id": session["vet_id"],

"createdOn": datetime.datetime.today(),

if len(pet_data["name"]) == 0 or len(pet_data["breed"]) == 0:

return render_template("error.html", message="Name and Breed cannot be Empty")

print(pet_data)

db = MongoDBHelper(collection="pet")

db.insert(pet_data)

return render_template(

"success.html",

message="{} added for customer {} successfully..".format(

pet_data["name"], pet_data["customer_email"]

),

@web_app.route("/add-consultation/<id>")

def add_consultation(id):

db = MongoDBHelper(collection="pet")

query = {"_id": ObjectId(id)}

pets = db.fetch(query)

pet = pets[0]

return render_template(

"add-consultation.html",

vet_id=session["vet_id"],

email=session["vet_email"],

name=session["vet_name"],

22 | Page
pet=pet,

@web_app.route("/save-consultation", methods=["POST"])

def save_consultation():

consultation_data = {

"problem": request.form["problem"],

"heartrate": int(request.form["heartrate"]),

"temperature": float(request.form["temperature"]),

"medicines": request.form["medicines"],

"pet_name": request.form["pet_name"],

"pet_id": request.form["pet_id"],

"customer_id": request.form["customer_id"],

"vet_id": session["vet_id"],

"createdOn": datetime.datetime.today(),

# Form Validation

if (

len(consultation_data["problem"]) == 0

or len(consultation_data["medicines"]) == 0

):

return render_template(

"error.html", message="Problem and Medicines, cannot be empty"

print(consultation_data)

db = MongoDBHelper(collection="consultation")

db.insert(consultation_data)

return render_template(

23 | Page
"success.html",

message="Consultation for Pet {} added successfully..".format(

consultation_data["pet_name"]

),

# To search Customer

@web_app.route("/search-customer", methods=["POST"])

def search_customer():

db = MongoDBHelper(collection="customer")

# To fetch customer where email and vet id will match

query = {"email": request.form["email"], "vet_id": session["vet_id"]}

customers = db.fetch(query)

if len(customers) == 1:

customer = customers[0]

return render_template(

"customer-profile.html",

customer=customer,

email=session["vet_email"],

name=session["vet_name"],

else:

return render_template("error.html", message="customer not found..")

@web_app.route("/update-pet-db/<id>", methods=["POST"])

def update_pet_in_db(id):

pet_data_to_update = {

"name": request.form["name"],

"breed": request.form["breed"],

24 | Page
"age": int(request.form["age"]),

"gender": request.form["gender"],

if len(pet_data_to_update["name"]) == 0 or len(pet_data_to_update["breed"]) == 0:

return render_template("error.html", message="Name and breed cannot be empty")

print(pet_data_to_update)

db = MongoDBHelper(collection="pet")

query = {"_id": ObjectId(id)}

db.update(pet_data_to_update, query)

return render_template(

"success.html",

message="{} updated successfully".format(pet_data_to_update["name"]),

@web_app.route("/update-pet/<id>")

def update_pet(id):

db_pet = MongoDBHelper(collection="pet")

query_pet = {"_id": ObjectId(id)}

pet = db_pet.fetch(query_pet)

if not pet: # Check if the list is empty

return render_template("error.html", message="Pet not found.")

pet = pet[0] # Fetch the first pet from the list

# Fetch the associated customer of the pet

db_customer = MongoDBHelper(collection="customer")

query_customer = {"_id": ObjectId(pet["customer_id"])}

customer = db_customer.fetch(query_customer)

if not customer: # Check if the list is empty

return render_template("error.html", message="Customer not found.")

25 | Page
customer = customer[0] # Fetch the first customer from the list

return render_template(

"update-pets.html",

email=session["vet_email"],

name=session["vet_name"],

customer=customer,

pet=pet,

@web_app.route("/delete-pet/<id>")

def delete_pet(id):

db = MongoDBHelper(collection="pet")

query = {"_id": ObjectId(id)}

customer = db.fetch(query)[0]

db.delete(query)

return render_template(

"success.html", message="Pet {} Deleted".format(customer["name"])

def main():

# In order to use session object in flask, we need to set some key as secret_key in app

web_app.secret_key = "vetsapp-key-1"

web_app.run(port=5001)

if __name__ == "__main__":

main()

26 | Page
Chapter 3: RESULTS AND DISCUSSIONS

Output:

Fig 3.1 Data of Customers

Fig 3.2 Login Page

27 | Page
Fig 3.3 Registration Page

Fig 3.4 Data of Pet

28 | Page

You might also like