Hello World!
Like many other people who are having to migrate from Heroku to other providers (), I found Render’s servers as a free hosting option.
After brute-forcing a bunch, I found the setting to allow one to deploy a Python Dash app on Render.
My test application has this skeleton:
import dash
import dash_auth
import dash_bootstrap_components as dbc
from dash import dcc, html, Output, Input, State, dash_table
app = dash.Dash(__name__,
meta_tags=[
{'name': 'viewport', 'content': 'width=device-width, initial-scale=1.0, maximum-scale=1.2, minimum-scale=0.5,'}],
external_stylesheets=[dbc.themes.QUARTZ])
server = app.server
app.title = 'Title'
app.layout = dbc.Container(fluid=True, children=[])
@app.callback(
[Output('some_stuff', 'children'),],
[Input('stuff', 'value')])
def display_something(value):
return value
if __name__ == '__main__':
app.run_server(debug=False)
The source code is in a private repository on Github (assets folder, requirements.txt, gitignore, the whole thing). So:
- I connect the repository to Render as a
Web Service
; - use the
Build Command = pip install --upgrade pip setuptools wheel && pip install -r requirements.txt
(I was getting errors because of the old pip version, so I am updating it). - and use the
Start Command
(and here is where I got so many failed deploys…)gunicorn my_app:server
.
And It works!
Other information that can help someone else replicate this result.
- The name of the file containing the application is
my_app.py
. - The version of python that I specify to Render is
3.8.0
(in Render, you specify this as an environmental variable during deployment, directly on Render’s dashboard).
Hope this helps people in a similar situation as me!
Thanks for your attention!