Deploy Flask to Render

Learn how to go LIVE with a Flask project using the Render Deployment Platform - Free Sample Included.

Flask & Stripe - Open-Source Starter deployed on Render
Flask & Stripe - Open-Source Starter deployed on Render

Hello! This article explains how to go live with a Flask project on Render, a popular deployment platform. For newcomers, Render supports the deployment for all major languages, Free Certificates, DDoS protection, and auto deploys from GIT. Thanks for reading!

Topics covered in this page
  • πŸ‘‰ Render Account Creation
  • πŸ‘‰ Create a new project
  • πŸ‘‰ Link GitHub Repository
  • πŸ‘‰ Trigger Manual Deployment
  • πŸ‘‰ Links & Resources

By following this step-by-step tutorial, anyone with basic programming knowledge should be able to deploy LIVE this Flask Mini eCommerce starter using Render. Let's Go!


Render Account Creation

The Sign UP is provided via classic Email and Social Authentication for well-known providers like GitHub, GitLab, or Google. Once the sign-up process is finished, the user is redirected to the dashboard.

Flask Render Deployment - Sign UP page
Flask Render Deployment - Sign UP page

Create a new project

All projects that use a dynamic language during runtime (Python, NodeJs) should be created as web services. This option can be found in the navigation bar, as shown below:

Flask Render Deployment - Create Web Service
Flask Render Deployment - Create Web Service

The next step is to associate a Flask project with the newly created web service. Render support account linkage with external platforms like GitHub, GitLab, and BitBucket. In our demonstration, an open-source repository is used as a working sample.

πŸ‘‰ Flask & Stripe - Mini eCommerce (MIT License)
Flask Render Deployment - Target Project
Flask Render Deployment - Target Project

πŸ‘‰ Here is the Render UI that allows the project association with the web service
Flask Render Deployment - Associate Repository
Flask Render Deployment - Associate Repository

The project settings

Before going LIVE, we need to configure the future web service. Here is the information required by Render:

  • βœ… The name of the project (mandatory)
  • βœ… The root of the project (leave it blank)
  • βœ… Environment: for a Flask project, we should select Python
  • βœ… Region: only if the location of the server is relevant
  • βœ… Source Branch: the main branch is used
  • βœ… Build Command: a simple BASH script is used
  • βœ… Start Command: the entry point, usually managed by Gunicorn

A visual representation of the above settings used to deploy the project can be found below:

Flask Render Deployment - Project Settings
Flask Render Deployment - Project Settings

The next step is to specify the billing plan for the project. Render platform, at the moment this material is edited, provides a free plan only for static sites built with React, Vue, Next, and all other frameworks.

Flask Render Deployment - Paid Pricing Plan
Flask Render Deployment - Paid Pricing Plan

The last step in this tutorial is to expand the "Advanced" section and provide a few Environment variables required by Flask and the Stripe feature.

  • βœ… Debug Flag: False (the recommended value in production)
  • βœ… SECRET_KEY variable: used to sign session secrets
  • βœ… SERVER_ADDRESS: Used by Stripe to redirect after a payment
  • βœ… Stripe Secrets: PRIVATE and PUBLIC keys (provided by Stripe)
Flask Render Deployment - App Environment Variables
Flask Render Deployment - App Environment Variables

An important aspect of the build is the automatic deployment that is enabled by default. In this sample, a manual build is used, just to have full control over the deployment flow.

Flask Render Deployment - Auto-Deploy Option
Flask Render Deployment - Auto-Deploy Option

Flask Render Deployment - First Deployment
Flask Render Deployment - First Deployment

Trigger Manual Deployment

The LIVE version of the project can be updated and even rollbacked anytime with ease via the UI. Here are the steps required by the LIVE update:

  • βœ… Access Manual Deploy Option
  • βœ… Select Deploy a specific commit
  • βœ… Add the commit HASH to be used (provided by Github)
  • βœ… Confirm/select the commit
  • βœ… Confirm the action and trigger the deploy
Step #1 - Select Specific Deployment Option
Flask Render Deployment - Manual Deploy (Step 1)
Flask Render Deployment - Manual Deploy (Step 1)

Step #2 - Select the GitHub commit to deploy
Flask Render Deployment - Manual Deploy, Select Commit
Flask Render Deployment - Manual Deploy, Select Commit

Once the Render platform starts the build, the state of the web service is flagged as "IN Progress" and soon the updated version should be LIVE.


Thanks for reading! For more resources, feel free to access: