
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.
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.
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.
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.
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.
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.
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.
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.
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 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