
Through this course we'll be creating a project and related source code. That will all be available on https://cfe.sh/github as well as the link below.
Through this course we'll be creating a project and related source code. That will all be available on https://cfe.sh/github as well as the link below.
Through this course we'll be creating a project and related source code. That will all be available on https://cfe.sh/github as well as the link below.
Through this course we'll be creating a project and related source code. That will all be available on https://cfe.sh/github as well as the link below.
Create your first Flask application by defining an app and a root route that returns hello world. Run it with flask run and set the FLASK_APP variable.
Discover how to enable local development for a flask web app with a WSGI file, import the app, and run it using flask run, without repeated env exports.
Convert a monolithic Flask app into a package by creating a landing package with __init__.py and a separate views module, importing the app, and wiring the routes.
Develop modular Flask components by creating profiles and jobs as separate modules with dedicated views and routes, ensure unique endpoints, and support detail and list views.
Learn how to render HTML templates in Flask by creating a templates folder, using render_template, and passing context variables to dynamic views, with auto reload during development.
Learn to pass context to templates with render_template, render single variables, lists, and dictionaries, and iterate over lists to render dynamic content like user names and profiles.
Place conditional logic in the Python view, not the template, by passing only the necessary context and rendering minimal content.
Learn how Jinja templates render dynamic context in Flask, using a base HTML with extends and blocks to build multiple pages, and optionally leverage Bootstrap for valid HTML emails.
Render json with flask using jsonify to serve data for rest APIs. Build simple routes like /jobs and test data delivery with curl.
Create a Flask landing page with a home view and template rendering, including a user form for name and email, and explain using post to send data to the backend.
Learn how to validate form fields in a flask app and implement csrf protection, handle post data, decode json, and prevent cross-site request forgery.
Learn about Python eval and the security risks of evaluating user input in forms; avoid using eval in request data to prevent form vulnerabilities and CSRF concerns.
learn to add CSRF protection to a Flask app by using Flask-WTF and WTForms, installing them with pip, wrapping the app with CSRFProtect, and testing with a curl post.
Create a landing form using flask-wtf by defining a landing form with full name and email string fields, integrating it into views, and validating on submit with csrf protection.
Learn to validate emails in Flask with wtforms by using the email validator. Implement a custom validate_email function that raises a validation error for school emails.
Learn to render a Flask-WTF form in a template by replacing raw inputs with form fields, adding labels and error messages, and styling with bootstrap for responsive validation.
Demonstrates configuring a Flask-WTF form with render_kw to apply Bootstrap classes and placeholders, styling the join button, and ensuring form validation and CSRF protection on a landing page.
Save form data into a database using SQLite with Flask and SQLAlchemy, install Flask-SQLAlchemy, configure the database path, and define models for the Flask app.
Create your first email signup model in Flask using SQLAlchemy, mapping full name and email to a database table with an auto-generated id, enforcing unique emails and preparing the database.
Toggle track modifications to true or false to emit signals on commit, update, or delete events; assess the overhead signaling introduces and adjust for your app’s needs.
Import the database and models in the flask shell, then query and filter email sign up instances, and perform crud operations with db.session and commit.
The lecture adds a model level save method to streamline create and update operations, handling db.session add, commit, and rollback, and enables delete via a unified CRUD approach.
Import the email sign up model and save form data to it, handle the CSRF token, and validate the email to avoid unique constraint errors and ensure proper model saving.
Learn to build a Flask detail view by retrieving an item by id via a dynamic URL, then render its detail page with a database instance and handle redirects.
Learn to fetch items by id with first_or_404 in Flask, ensuring a 404 not found page when the database item is missing, demonstrated by visiting a non-existent route.
Build an update view in Flask that pre-fills form data from a database instance and posts updates to the server.
Learn to implement an update view in Flask by using a hidden id field, validating and updating full name and email, and enforcing email uniqueness against the current record.
Create a list view at /items with a get method, pass an object list (query set) to the template, render the items, and implement item redirects.
Create a nav bar template and include it in the base with a relative path, then apply container-fluid styling, a top margin, and add navigation links.
Learn to build dynamic navigation in Flask by using url_for to generate links like home and items, and implement redirects with url_for and function arguments.
Learn how url_for with arguments builds dynamic redirects in a Flask app by passing item ids to item detail routes, ensuring consistent paths across the app.
Implement signals in SQLAlchemy to run code before and after insert, update, or delete operations, enabling emails, webhooks, or celery tasks without cluttering views.
Learn to change a Flask app's database schema after setup using Flask-Migrate, including initializing migrations, detecting changes, upgrading the database, and testing in the shell.
Reset a flask project by deleting the database and migrations, run flask db init, then flask db migrate and flask db upgrade to apply model changes and recreate the database.
Add a content field and a UTC timestamp with default values to the email signup model, index the timestamp for faster lookups, and generate and apply migrations with flask migrate.
Learn to create a lightweight password protected view in Flask by building a form with a password field, validating input, and conditionally revealing items with a redirect.
Prepare a production-ready Flask landing page by integrating a GitHub image, using Bootstrap for centering and layout, refining the form with form-group, and simplifying navigation before launch.
Install and run gunicorn to replace the Flask development server for production, point it to the landing app, and configure workers and timeout for deployment with a Procfile on Heroku.
Deploy a Flask landing page using git and Heroku, initialize a repo, commit changes, and push to the Heroku master; troubleshoot missing modules with pip install and check logs.
Learn to implement a production ready success page in a Flask app, wire templates and navigation, and test locally with unicorn before deploying on Heroku.
Learn how to attach a custom domain to your flask landing app with heroku domains:add, configure DNS records at your registrar, and set up redirects to go live.
Flask is a flexible web framework written in Python. It's narrow in scope so that means it's much easier to learn.
A web application with Flask can be as simple as 1 function with 4 total lines of code. Regardless of your technical background, what I want that to signal to you is that Flask can be very very small in scope which means a much smaller learning curve.
Of course, you can add all kinds of technology (such as a SQL database), to make Flask even more functional but that's completely optional.
Here's a few use cases of flask:
Quick and fast RESTful API service
Microservice for offloading tasks from a main app (such as a Django app) to handle all sorts of processing (creating thumbnails, running machine learning, doing web scraping, sending notifications, calculating bills and invoices, and so on)
Full fledged Web Application (user login, data storage, user sharing, etc)
Integrating into an iot device to control sensors, motors, servos, mics, cameras, and so on.
As middleman between services like Shopify and Zapier. (Ie you need to analyze some customer data from Shopify before it becomes a zap?)
Anything you can image
Flask, as with many Python Package, can almost do anything you can image. And there's a good chance that someone has already created a package to help your project's development time increase in a big way.
Django vs Flask
These two are compared all the time. At their core, they attempt to accomplish the same thing: web application development. But they do it in very different ways.
First off, remember that Python is flexible so Django and Flask are flexible.
Flask can be more flexible but increases development time on larger projects
Django cuts long term development time on larger projects
Flask is smaller as in file size
Django is bigger but has many security features built in (such as CSRF and clickjacking)
Django has an ORM
Flask can easily be integrated into SQLAlchemy
If you know Flask, learning Django will be easier and vice versa. In fact, once you know any python web framework it's much easier to learn others so you can find the best library that your project needs.
Are you ready to begin?
Let's do this!
Justin