Deploying a Plotly Dash Webapp on Render: A Step-by-Step Guide¶
I like to create web applications in Python, especially using the Plotly Dash framework. One of my favorite projects is a Sudoku Solver that’s powered by Mixed-Integer Linear Programming (check it out at sudoku.quiradata.com). I understand the excitement of bringing a project to life on the web. In this guide, I’ll walk you through the process I used to deploy my Sudoku app on Render.
Prerequisites¶
- A Render account: Sign up at render.com
- A GitHub account and repository: This should contain your Python Dash application project
Update Python Code and Create requirements.txt¶
Setting Up intro point¶
-
Locate the section of your python application file where the
app
variable is defined. It should look something like this: -
Add the following line immediately after the
app
definition:
This exposes your Dash app’s Flask server instance, which is necessary for deployment.
Creating/Updating requirements.txt
¶
-
In the root directory of your repository, create a file named
requirements.txt
. You can use pipreqs to generate the requirements file based on imports in project. For example: -
Include gunicorn at the end of the requirements.txt file. Gunicorn is a Python HTTP server that efficiently handles web requests.
Setting Up a New Web Service on Render¶
- Log in to Render and navigate to your dashboard.
- Click +New / Web Service.
- Provide the URL of your Public GitHub repository containing the Dash app.
- Configure the service by:
- Giving your service a unique name.
- Language: Python 3
- Branch: The Git branch to build and deploy. In my case master
- Build Command: Render runs this command to build your app before each deploy
-
Start Command: Render runs this command to start your app with each deploy
-
Hit Deploy Web Service to finalize the setup.
You're Live!¶
- Render will now build and deploy your application. This may take a few minutes.
- Once deployment is complete, you’ll see a live link to your application.
Your Dash app is now live on Render and accessible from anywhere.