SlideShare a Scribd company logo
Building Back-
End Applications
Using Flask Framework for Web Development
Introduction
This presentation covers the essentials of building back-end
applications using Flask. We'll dive deep into routing, templates, and
building a simple multi-page app, enabling a dynamic user experience.
Flask Basics
01
Routing:
• App Routing means mapping the URLs to a specific
function that will handle the logic for that URL.
• Example: In our application, the URL (“/”) is associated
with the root URL.
from flask import Flask
app = Flask(__name__)
# Pass the required route
@app.route("/hello")
def hello():
return "Hello, Welcome to GeeksForGeeks"
@app.route("/")
def index():
return "Homepage of GeeksForGeeks"
if __name__ == "__main__":
app.run(debug=True)
Templates:
• A flask template is a template of a webpage that can be used by web developers to reduce the
hectic work of writing the code for each webpage of a website.
• For example, web developers can create a template that has headers like a navbar and footer
which is the same for all web pages. so instead of writing code for the header and footer of
every webpage, we can use that template.
render_template() method :
• The render_template() method, allows us to fetch the HTML files, and, pass them to the browser.
• Hence, instead of rendering, raw string or inline HTML code, from the backend code to the browser, we can have
a separate HTML file, passed to the client. The steps followed, to use the same, are as follows.
App.py
from flask import Flask,render_template
app = Flask(__name__)
@app.route('/')
def home():
return render_template ('home.html')
@app.route('/about')
def about():
return render_template ('about.html')
if __name__=="__main__":
app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-
width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>this is about page
</p>
<a href="/">home</a>
<a
href="/about">about</a>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,
initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>this is home page </p>
<a href="/">home</a>
<a
href="/about">about</a>
</body>
</html>
home.html about.html
Static files:
• Flask allows you to serve static files like CSS, JavaScript, and images through a
dedicated folder, typically named 'static’.
• These files are essential for enhancing the visual aspects of the web application
and improving user experience.
• In your Flask application, you can refer to these static files in your templates
using the url_for() function, making it easy to manage paths efficiently and ensure
that your assets load correctly across different environments.
Simple Flask
App
02
Creating a multi-
page Flask app
(e.g., Home,
About, Contact)
To create a multi-page application in Flask, you define several routes
that correspond to different views in your app, such as Home, About,
and Contact. Each route is linked to a dedicated function that renders a
specific template. By organizing your app this way, you create a
cohesive user experience, allowing for seamless navigation between
different sections of the application, enhancing usability and
engagement.
Passing data from the back-end to the front-
end
Flask enables seamless data transfer from the back-end to the front-end using
template rendering.
Variables defined in your Flask route functions can be passed to your templates
when rendering them, allowing you to display dynamic content to users.
This interaction can include user input, database query results, or any other data
necessary to enhance the application's functionality and user interface.
Building a small Flask app with multiple pages
and dynamic content
Building a small Flask application involves integrating all the concepts learned, such as routing, templates,
and serving static files. Start by setting up your route handlers for each page, ensuring they render the
correct templates while passing necessary data. Incorporate dynamic elements that adjust based on user
interactions or other inputs, allowing for a richer user experience. Through practice, students can solidify
their understanding of Flask and create functional web applications that reflect their skills.
Conclusions
The presentation highlighted key aspects of building back-end
applications using Flask, including essential routing, templates,
and static file management for enhanced web functionality.
Students are encouraged to apply this knowledge to develop
multi-page applications with dynamic content, improving their
programming skills and understanding of the Flask framework.
CREDITS: This presentation template was created by Slidesgo, and
includes icons by Flaticon, and infographics & images by Freepik
Thank you!
Do you have any questions?

More Related Content

PPTX
Flask Application ppt to understand the flask
ODP
Exploring Symfony's Code
PPTX
cakephp UDUYKTHA (1)
PPT
Intro to Application Express
PDF
Making Of PHP Based Web Application
PDF
DYNAMIC CONTENT TECHNOLOGIES ASP(ACTIVE SERVER PAGES)
PPTX
PPTX
Introduction to using jQuery with SharePoint
Flask Application ppt to understand the flask
Exploring Symfony's Code
cakephp UDUYKTHA (1)
Intro to Application Express
Making Of PHP Based Web Application
DYNAMIC CONTENT TECHNOLOGIES ASP(ACTIVE SERVER PAGES)
Introduction to using jQuery with SharePoint

Similar to This is the js ppt where I have design about class 2 of the js (20)

PPTX
Web development it slideWeb development it slidemy web development slide-...
PPT
Websites Unlimited - Pay Monthly Websites
PDF
Building Workflow Applications Through the Web
PDF
How to build and deploy app on Replit
PDF
Intro to mobile web application development
PDF
Frontend Interview Questions PDF By ScholarHat
PPTX
ashish ppt webd.pptx
PDF
Progressive Web Apps - deep dive
PDF
sveltekit-en.pdf
PDF
Make SharePoint Look Not Like SharePoint - SPSNashville - Cathy Dew
PPTX
Front End Development | Introduction
PPSX
web devs ppt.ppsx
PPT
Introduction to Alfresco Surf Platform
DOCX
A report on mvc using the information
PPTX
Getting started with hot towel spa
PPTX
Oracle Endeca Developer's Guide
DOCX
ANGULAR JS LAB MANUAL(final) vtu2021 sch
PDF
AEM Sightly Deep Dive
PPTX
flask.pptx
PPTX
Laravel overview
Web development it slideWeb development it slidemy web development slide-...
Websites Unlimited - Pay Monthly Websites
Building Workflow Applications Through the Web
How to build and deploy app on Replit
Intro to mobile web application development
Frontend Interview Questions PDF By ScholarHat
ashish ppt webd.pptx
Progressive Web Apps - deep dive
sveltekit-en.pdf
Make SharePoint Look Not Like SharePoint - SPSNashville - Cathy Dew
Front End Development | Introduction
web devs ppt.ppsx
Introduction to Alfresco Surf Platform
A report on mvc using the information
Getting started with hot towel spa
Oracle Endeca Developer's Guide
ANGULAR JS LAB MANUAL(final) vtu2021 sch
AEM Sightly Deep Dive
flask.pptx
Laravel overview
Ad

More from AltafSMT (6)

PPTX
This ppt is for the java script chapter 2
PPTX
chatgpt seminar ppt.pptx
PPTX
self operating maps
PPTX
silverlight1.pptx
PPTX
ML_Internship Presentation_Infidata_2021.pptx
PPTX
altafppt.pptx
This ppt is for the java script chapter 2
chatgpt seminar ppt.pptx
self operating maps
silverlight1.pptx
ML_Internship Presentation_Infidata_2021.pptx
altafppt.pptx
Ad

Recently uploaded (20)

PPTX
Introduction to Knowledge Engineering Part 1
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PDF
Business Analytics and business intelligence.pdf
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
Computer network topology notes for revision
PPTX
Qualitative Qantitative and Mixed Methods.pptx
PPTX
climate analysis of Dhaka ,Banglades.pptx
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PDF
annual-report-2024-2025 original latest.
PDF
Mega Projects Data Mega Projects Data
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Supervised vs unsupervised machine learning algorithms
Introduction to Knowledge Engineering Part 1
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
Business Analytics and business intelligence.pdf
Fluorescence-microscope_Botany_detailed content
Computer network topology notes for revision
Qualitative Qantitative and Mixed Methods.pptx
climate analysis of Dhaka ,Banglades.pptx
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
IBA_Chapter_11_Slides_Final_Accessible.pptx
Miokarditis (Inflamasi pada Otot Jantung)
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
annual-report-2024-2025 original latest.
Mega Projects Data Mega Projects Data
Reliability_Chapter_ presentation 1221.5784
Supervised vs unsupervised machine learning algorithms

This is the js ppt where I have design about class 2 of the js

  • 1. Building Back- End Applications Using Flask Framework for Web Development
  • 2. Introduction This presentation covers the essentials of building back-end applications using Flask. We'll dive deep into routing, templates, and building a simple multi-page app, enabling a dynamic user experience.
  • 4. Routing: • App Routing means mapping the URLs to a specific function that will handle the logic for that URL. • Example: In our application, the URL (“/”) is associated with the root URL.
  • 5. from flask import Flask app = Flask(__name__) # Pass the required route @app.route("/hello") def hello(): return "Hello, Welcome to GeeksForGeeks" @app.route("/") def index(): return "Homepage of GeeksForGeeks" if __name__ == "__main__": app.run(debug=True)
  • 6. Templates: • A flask template is a template of a webpage that can be used by web developers to reduce the hectic work of writing the code for each webpage of a website. • For example, web developers can create a template that has headers like a navbar and footer which is the same for all web pages. so instead of writing code for the header and footer of every webpage, we can use that template. render_template() method : • The render_template() method, allows us to fetch the HTML files, and, pass them to the browser. • Hence, instead of rendering, raw string or inline HTML code, from the backend code to the browser, we can have a separate HTML file, passed to the client. The steps followed, to use the same, are as follows.
  • 7. App.py from flask import Flask,render_template app = Flask(__name__) @app.route('/') def home(): return render_template ('home.html') @app.route('/about') def about(): return render_template ('about.html') if __name__=="__main__": app.run(debug=True)
  • 8. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device- width, initial-scale=1.0"> <title>Document</title> </head> <body> <p>this is about page </p> <a href="/">home</a> <a href="/about">about</a> </body> </html> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <p>this is home page </p> <a href="/">home</a> <a href="/about">about</a> </body> </html> home.html about.html
  • 9. Static files: • Flask allows you to serve static files like CSS, JavaScript, and images through a dedicated folder, typically named 'static’. • These files are essential for enhancing the visual aspects of the web application and improving user experience. • In your Flask application, you can refer to these static files in your templates using the url_for() function, making it easy to manage paths efficiently and ensure that your assets load correctly across different environments.
  • 11. Creating a multi- page Flask app (e.g., Home, About, Contact) To create a multi-page application in Flask, you define several routes that correspond to different views in your app, such as Home, About, and Contact. Each route is linked to a dedicated function that renders a specific template. By organizing your app this way, you create a cohesive user experience, allowing for seamless navigation between different sections of the application, enhancing usability and engagement.
  • 12. Passing data from the back-end to the front- end Flask enables seamless data transfer from the back-end to the front-end using template rendering. Variables defined in your Flask route functions can be passed to your templates when rendering them, allowing you to display dynamic content to users. This interaction can include user input, database query results, or any other data necessary to enhance the application's functionality and user interface.
  • 13. Building a small Flask app with multiple pages and dynamic content Building a small Flask application involves integrating all the concepts learned, such as routing, templates, and serving static files. Start by setting up your route handlers for each page, ensuring they render the correct templates while passing necessary data. Incorporate dynamic elements that adjust based on user interactions or other inputs, allowing for a richer user experience. Through practice, students can solidify their understanding of Flask and create functional web applications that reflect their skills.
  • 14. Conclusions The presentation highlighted key aspects of building back-end applications using Flask, including essential routing, templates, and static file management for enhanced web functionality. Students are encouraged to apply this knowledge to develop multi-page applications with dynamic content, improving their programming skills and understanding of the Flask framework.
  • 15. CREDITS: This presentation template was created by Slidesgo, and includes icons by Flaticon, and infographics & images by Freepik Thank you! Do you have any questions?