Git Product home page Git Product logo

python-p4-intro-to-flask's Introduction

Intro to Flask

Learning Goals

  • Describe the components of a web application framework.
  • Build and run a Flask application on your computer.
  • Manipulate and test the structure of a request object.
  • Extend a Flask application to meet the unique requirements of different projects.

Key Vocab

  • Web Framework: software that is designed to support the development of web applications. Web frameworks provide built-in tools for generating web servers, turning Python objects into HTML, and more.
  • Extension: a package or module that adds functionality to a Flask application that it does not have by default.
  • Request: an attempt by one machine to contact another over the internet.
  • Client: an application or machine that accesses services being provided by a server through the internet.
  • Web Server: a combination of software and hardware that uses Hypertext Transfer Protocol (HTTP) and other protocols to respond to requests made over the internet.
  • Web Server Gateway Interface (WSGI): an interface between web servers and applications.
  • Template Engine: software that takes in strings with tokenized values, replacing the tokens with their values as output in a web browser.

Introduction

In Phase 2, we learned about web applications and React. In Phase 3, we learned about the fundamentals of Python and SQL. In Phase 4, we are going to use all of that knowledge as we build Python-based web applications with Flask, a web microframework.

A web framework is a tool that is designed to support the development of web applications. This is similar to React, though true web frameworks provide a degree of scaffolding to direct you in the construction of your project. Certain frameworks like Django do everything under the sun: they give you the power of Python, an ORM, a web server, authentication, and more. Microframeworks like Flask handle some basic functionality, but more specific duties require extensions. SQLAlchemy is a key extension that we will be using in Phase 4.

While Flask does not come with all of the features that Django does, it is no less powerful: Flask is built to carry out a web application's duties in the most simple, Pythonic way possible, which allows it to cooperate with almost any PyPI library. (That being said, there are still Flask-specific versions of these libraries- usually named "Flask-Libraryname".)


The History of Flask

Flask logo with text: "web development, one drop at a time"

Flask was originally developed by Armin Ronacher as an April Fool's joke in 2010. His goal was to make the smallest viable web framework and pitch it for use in production code. He leveraged some of his other projects in the process: Werkzeug (German for "work stuff") as an interface between the application and server, Jinja to turn Python code into HTML, and Click, a CLI building tool that we mentioned at the end of Phase 3.

Competing with the well-established and generally beloved Django, he felt that his proposal would be met with a laugh. After all, Flask didn't do very much. All of the source code fit comfortably into one file! Much to Ronacher's surprise, people loved Flask and began submitting hundreds of pull requests on the repo, suggesting changes to expand its core functionality and compatibility with different styles of coding.

Ronacher couldn't handle all of these requests himself, so he created the Pallets Projects as a central location for Flask and his other projects. If you visit the homepage, you'll see the docs for Werkzeug, Jinja, and Click. This might be a useful page to bookmark, as most of the important documentation for Phase 4 is right there!

Because it is useful for small and large projects and a wide variety of tasks, Flask is now the most used Python web framework: It is used at Netflix, Reddit, Airbnb, Lyft, Uber, and Mozilla, among many, many other companies. Flask isn't the perfect tool for every task, but we will explore several common use cases and introduce you to many generalizable key concepts in full-stack web development.


What to Look Forward to in Phase 4

In Phase 4, we will cover a number of topics in web development:

  • Core Components of Python Web Applications
  • Web Scraping
  • Application Programming Interfaces (APIs)
  • Retrieving Data from APIs
  • Building APIs with Flask
  • Restorative State Transfer (REST)
  • Forms and Validations
  • Client-Server Communication
  • Serialization
  • Full-Stack Development with Flask and React
  • Deploying a Web Application

Coming out of Phase 4, you will know how to build databases, Flask applications, and React frontends. This will give you all the tools you need to get started on your capstone project, as well as any other projects you might have in mind.

Happy coding!

Resources

  • Flask Documentation
  • Armin Ronacher
  • Werkzeug Documentation
  • Jinja Documentation
  • Click Documentation
  • The Pallets Projects

python-p4-intro-to-flask's People

Contributors

professor-ben avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.