SlideShare uma empresa Scribd logo
1 de 18
Flask is one of the easiest ways to bring your Python
skills online. It's a great micro framework used by
thousands of people to create prototypes and small
web apps.
Introduction:
 Flask is a micro web application framework written
in Python and based on the Werkzeug toolkit(WSGI is the Web
Server Gateway Interface. It is a specification that describes
how a web server communicates with web applications, and how
web applications can be chained together to process one request.
WSGI is Python standard ) and Jinja2 template
engine[Template engines are tools to separate program-logic
and presentation into two independent parts. This makes the
development of both logic and presentation easier, improves
flexibility and eases modification and maintenance].
 As of 2015, the latest stable version of Flask is 0.10.1.
 Examples of applications that make use of the Flask framework
are Pinterest, LinkedIn, as well as the community web page
for Flask itself.
Flask:
 Flask is called a micro framework because it does not
presume or force a developer to use a particular tool or
library . It has no database abstraction layer, form
validation, or any other components where pre-
existing third-party libraries provide common
functions. However, Flask supports extensions that can
add application features as if they were implemented
in Flask itself. Extensions exist for object-relational
mappers, form validation, upload handling, various
open authentication technologies and several common
framework related tools.
Features:
 Contains development server and debugger
 Integrated support for unit testing
 RESTful request dispatching
 Uses Jinja2 templating
 Support for secure cookies (client side sessions)
 100% WSGI 1.0 compliant
 Unicode-based
 Extensive documentation
 Google App Engine Compatibility
 Extensions available to enhance features desired
Installing Flask:
 You will need Python 2.6 or higher to get started
 (All dependencies are installed by using `pip install Flask`.
I encourage you to use a virtualenv.) virtualenv is a tool to
create isolated Python environments. Virtualenv creates a
folder which contains all the necessary executables to use
the packages that a Python project would need.
 Before getting started, we need to install Flask. Because
systems vary, things can sporadically go wrong during these
steps. If they do, like we all do, just Google the error
message or leave a comment describing the problem.
VERTUALENV:
Example:
 from flask import Flask app = Flask(__name__)
@app.route("/") def hello(): return "Hello World!" if
__name__ == "__main__": app.run()
Hello world:
Debug Mode:
app.run(debug=True)
SQLALCHEMY
For larger applications use SQLAlchemy that handles database
connections in a more intelligent way, allows you to target
different relational databases at once and more.
FORMS:
TUTORIAL: blogging application flaskr
1. User sign in and out with credentials specified in the configuration. Only one user is supported.
2. when the user is logged in they can add new entries to the page consisting of a text-only title and
some HTML for the text.
3. The page shows all entries so far in reverse order (newest on top) and the user can add new ones from there if
logged in
Setting up the Project Structure
 Let's create a couple of folders
and files within flaskapp/ to
keep our web app organized.
 Within flaskapp/, create a folder, app/, to contain all your
files. Inside app/, create a folder static/; this is where we'll
put our web app's images, CSS, and JavaScript files, so
create folders for each of those, as demonstrated above.
Additionally, create another folder, templates/, to store the
app's web templates. Create an empty Python
file routes.py for the application logic, such as URL
routing.
 And no project is complete without a helpful description,
so create a README.mdfile as well.
Creating a Home page:
 As a first step, we'll define our page layout in a skeleton
HTML document layout.html and put it inside
the templates/ folder
app/templates/layout.html
 let's create another file home.html:
app/templates/home.html
 layout.html defines all of the common elements of
your site
 home.html is placed in the templates/ folder. Now, we
need to map a URL to it so we can view it in the
browser. Let's open up routes.py and do this:
 app/routes.py
 Return to the command line, and type:
$ python routes.py
 Visit http://localhost:5000/ in your favorite web
browser.
REFRENCE LINKS:
 WIKIPIDIA
 http://flask.pocoo.org/
 Slideshare.com
 www.fullstackpython.com
 www.google.co.in
 http://code.tutsplus.com/tutorials/an-introduction-
to-pythons-flask-framework--net-28822
MADE BY:
MAMTA
RUSTAMJI INSTITUTE OF TECHNOLOGY

Mais conteúdo relacionado

Mais procurados

A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
Ganga Ram
 

Mais procurados (20)

Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Django - Python MVC Framework
Django - Python MVC FrameworkDjango - Python MVC Framework
Django - Python MVC Framework
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
Spring boot
Spring bootSpring boot
Spring boot
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
React native
React nativeReact native
React native
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Web api
Web apiWeb api
Web api
 
Reactjs
Reactjs Reactjs
Reactjs
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Flask Basics
Flask BasicsFlask Basics
Flask Basics
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
React Native
React NativeReact Native
React Native
 
Spring boot
Spring bootSpring boot
Spring boot
 
Full stack web development
Full stack web developmentFull stack web development
Full stack web development
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Solid principles
Solid principlesSolid principles
Solid principles
 

Semelhante a Flask

Django Article V0
Django Article V0Django Article V0
Django Article V0
Udi Bauman
 
0506-django-web-framework-for-python.pdf
0506-django-web-framework-for-python.pdf0506-django-web-framework-for-python.pdf
0506-django-web-framework-for-python.pdf
radhianiedjan1
 
Asp net mvc
Asp net mvcAsp net mvc
Asp net mvc
bgrynko
 

Semelhante a Flask (20)

Spring hibernate tutorial
Spring hibernate tutorialSpring hibernate tutorial
Spring hibernate tutorial
 
M365 global developer bootcamp 2019 Intro to SPFx Version
M365 global developer bootcamp 2019 Intro to SPFx VersionM365 global developer bootcamp 2019 Intro to SPFx Version
M365 global developer bootcamp 2019 Intro to SPFx Version
 
CONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEMCONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEM
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 
Plugins 2.0: The Overview
Plugins 2.0: The OverviewPlugins 2.0: The Overview
Plugins 2.0: The Overview
 
How create react app help in creating a new react applications
How create react app help in creating a new react applications How create react app help in creating a new react applications
How create react app help in creating a new react applications
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
sveltekit-en.pdf
sveltekit-en.pdfsveltekit-en.pdf
sveltekit-en.pdf
 
Flask
FlaskFlask
Flask
 
Python Web Framework – A Detailed List of Web Frameworks in Python
Python Web Framework – A Detailed List of Web Frameworks in PythonPython Web Framework – A Detailed List of Web Frameworks in Python
Python Web Framework – A Detailed List of Web Frameworks in Python
 
CTE 323 - Lecture 1.pptx
CTE 323 - Lecture 1.pptxCTE 323 - Lecture 1.pptx
CTE 323 - Lecture 1.pptx
 
django
djangodjango
django
 
Django simplified : by weever mbakaya
Django simplified : by weever mbakayaDjango simplified : by weever mbakaya
Django simplified : by weever mbakaya
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
 
Open Social Frameworks
Open Social FrameworksOpen Social Frameworks
Open Social Frameworks
 
Cakephp manual-11
Cakephp manual-11Cakephp manual-11
Cakephp manual-11
 
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
Rewriting a Plugin Architecture 3 Times to Harness the API EconomyRewriting a Plugin Architecture 3 Times to Harness the API Economy
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
 
Django Article V0
Django Article V0Django Article V0
Django Article V0
 
0506-django-web-framework-for-python.pdf
0506-django-web-framework-for-python.pdf0506-django-web-framework-for-python.pdf
0506-django-web-framework-for-python.pdf
 
Asp net mvc
Asp net mvcAsp net mvc
Asp net mvc
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 

Flask

  • 1. Flask is one of the easiest ways to bring your Python skills online. It's a great micro framework used by thousands of people to create prototypes and small web apps.
  • 2. Introduction:  Flask is a micro web application framework written in Python and based on the Werkzeug toolkit(WSGI is the Web Server Gateway Interface. It is a specification that describes how a web server communicates with web applications, and how web applications can be chained together to process one request. WSGI is Python standard ) and Jinja2 template engine[Template engines are tools to separate program-logic and presentation into two independent parts. This makes the development of both logic and presentation easier, improves flexibility and eases modification and maintenance].  As of 2015, the latest stable version of Flask is 0.10.1.  Examples of applications that make use of the Flask framework are Pinterest, LinkedIn, as well as the community web page for Flask itself.
  • 3. Flask:  Flask is called a micro framework because it does not presume or force a developer to use a particular tool or library . It has no database abstraction layer, form validation, or any other components where pre- existing third-party libraries provide common functions. However, Flask supports extensions that can add application features as if they were implemented in Flask itself. Extensions exist for object-relational mappers, form validation, upload handling, various open authentication technologies and several common framework related tools.
  • 4. Features:  Contains development server and debugger  Integrated support for unit testing  RESTful request dispatching  Uses Jinja2 templating  Support for secure cookies (client side sessions)  100% WSGI 1.0 compliant  Unicode-based  Extensive documentation  Google App Engine Compatibility  Extensions available to enhance features desired
  • 5. Installing Flask:  You will need Python 2.6 or higher to get started  (All dependencies are installed by using `pip install Flask`. I encourage you to use a virtualenv.) virtualenv is a tool to create isolated Python environments. Virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need.  Before getting started, we need to install Flask. Because systems vary, things can sporadically go wrong during these steps. If they do, like we all do, just Google the error message or leave a comment describing the problem.
  • 7. Example:  from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run()
  • 10. SQLALCHEMY For larger applications use SQLAlchemy that handles database connections in a more intelligent way, allows you to target different relational databases at once and more.
  • 12. TUTORIAL: blogging application flaskr 1. User sign in and out with credentials specified in the configuration. Only one user is supported. 2. when the user is logged in they can add new entries to the page consisting of a text-only title and some HTML for the text. 3. The page shows all entries so far in reverse order (newest on top) and the user can add new ones from there if logged in
  • 13. Setting up the Project Structure  Let's create a couple of folders and files within flaskapp/ to keep our web app organized.  Within flaskapp/, create a folder, app/, to contain all your files. Inside app/, create a folder static/; this is where we'll put our web app's images, CSS, and JavaScript files, so create folders for each of those, as demonstrated above. Additionally, create another folder, templates/, to store the app's web templates. Create an empty Python file routes.py for the application logic, such as URL routing.  And no project is complete without a helpful description, so create a README.mdfile as well.
  • 14. Creating a Home page:  As a first step, we'll define our page layout in a skeleton HTML document layout.html and put it inside the templates/ folder app/templates/layout.html
  • 15.  let's create another file home.html: app/templates/home.html  layout.html defines all of the common elements of your site  home.html is placed in the templates/ folder. Now, we need to map a URL to it so we can view it in the browser. Let's open up routes.py and do this:
  • 16.  app/routes.py  Return to the command line, and type: $ python routes.py  Visit http://localhost:5000/ in your favorite web browser.
  • 17. REFRENCE LINKS:  WIKIPIDIA  http://flask.pocoo.org/  Slideshare.com  www.fullstackpython.com  www.google.co.in  http://code.tutsplus.com/tutorials/an-introduction- to-pythons-flask-framework--net-28822