├── runtime.txt ├── Procfile ├── assets └── favicon.ico ├── requirements.txt ├── README.md ├── app.py └── .gitignore /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.7.8 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn app:server 2 | -------------------------------------------------------------------------------- /assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/austinlasseter/flying-dog-beers/HEAD/assets/favicon.ico -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | certifi==2019.6.16 2 | chardet==3.0.4 3 | Click==7.0 4 | dash==1.1.1 5 | dash-core-components==1.1.1 6 | dash-html-components==1.0.0 7 | dash-renderer==1.0.0 8 | dash-table==4.1.0 9 | dask==2.1.0 10 | decorator==4.4.0 11 | Flask==1.1.1 12 | Flask-Compress==1.4.0 13 | gunicorn==19.9.0 14 | html5lib==1.0.1 15 | idna==2.8 16 | ipython-genutils==0.2.0 17 | itsdangerous==1.1.0 18 | Jinja2==2.11.3 19 | jupyter-core==4.5.0 20 | MarkupSafe==1.1.1 21 | nbformat==4.4.0 22 | numpy==1.16.4 23 | pandas==0.24.2 24 | plotly==4.1.0 25 | pytz==2019.1 26 | six==1.12.0 27 | traitlets==4.3.2 28 | Werkzeug==0.15.4 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # How to deploy a simple Plotly Dash app on Heroku 2 | 3 | * You can view the finished app on [Heroku](https://flying-dog.herokuapp.com/). 4 | * Take a moment to read my [Medium post about how to deploying this app](https://austinlasseter.medium.com/deploy-a-plotly-dash-app-on-heroku-4d2c3224230) 5 | * I also have a gallery of simple Dash apps for learning [here](https://github.com/austinlasseter/plotly_dash_tutorial/blob/master/06%20Heroku%20examples/list%20of%20resources.md). 6 | * If you'd like to learn even more about Plotly Dash, check out my [tutorial repo](https://github.com/austinlasseter/plotly_dash_tutorial) on github!. 7 | * If you'd like to tinker with the colors of your app, try using HEX codes from [HTML Color Codes](https://htmlcolorcodes.com/). 8 | * The `assets` folder contains a file called `favicon.ico` -- you can find and download customized favicons [here](https://www.favicon.cc/). Just replace the current favicon with a new one. 9 | 10 | 11 | ### Additional Reading 12 | * Plotly’s [Dash deployment guide](https://dash.plotly.com/deployment) 13 | * Heroku’s [deployment guide](https://devcenter.heroku.com/articles/getting-started-with-python) 14 | * Fantastic [blog post](https://towardsdatascience.com/deploying-your-dash-app-to-heroku-the-magical-guide-39bd6a0c586c) that dives deep 15 | * Excellent [YouTube tutorial](https://www.youtube.com/watch?v=b-M2KQ6_bM4&feature=youtu.be) 16 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import dash 2 | import dash_core_components as dcc 3 | import dash_html_components as html 4 | import plotly.graph_objs as go 5 | 6 | ########### Define your variables 7 | beers=['Chesapeake Stout', 'Snake Dog IPA', 'Imperial Porter', 'Double Dog IPA'] 8 | ibu_values=[35, 60, 85, 75] 9 | abv_values=[5.4, 7.1, 9.2, 4.3] 10 | color1='darkred' 11 | color2='orange' 12 | mytitle='Beer Comparison' 13 | tabtitle='beer!' 14 | myheading='Flying Dog Beers' 15 | label1='IBU' 16 | label2='ABV' 17 | githublink='https://github.com/austinlasseter/flying-dog-beers' 18 | sourceurl='https://www.flyingdog.com/beers/' 19 | 20 | ########### Set up the chart 21 | bitterness = go.Bar( 22 | x=beers, 23 | y=ibu_values, 24 | name=label1, 25 | marker={'color':color1} 26 | ) 27 | alcohol = go.Bar( 28 | x=beers, 29 | y=abv_values, 30 | name=label2, 31 | marker={'color':color2} 32 | ) 33 | 34 | beer_data = [bitterness, alcohol] 35 | beer_layout = go.Layout( 36 | barmode='group', 37 | title = mytitle 38 | ) 39 | 40 | beer_fig = go.Figure(data=beer_data, layout=beer_layout) 41 | 42 | 43 | ########### Initiate the app 44 | external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] 45 | app = dash.Dash(__name__, external_stylesheets=external_stylesheets) 46 | server = app.server 47 | app.title=tabtitle 48 | 49 | ########### Set up the layout 50 | app.layout = html.Div(children=[ 51 | html.H1(myheading), 52 | dcc.Graph( 53 | id='flyingdog', 54 | figure=beer_fig 55 | ), 56 | html.A('Code on Github', href=githublink), 57 | html.Br(), 58 | html.A('Data Source', href=sourceurl), 59 | ] 60 | ) 61 | 62 | if __name__ == '__main__': 63 | app.run_server() 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | pip-wheel-metadata/ 26 | share/python-wheels/ 27 | *.egg-info/ 28 | .installed.cfg 29 | *.egg 30 | MANIFEST 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .nox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *.cover 52 | *.py,cover 53 | .hypothesis/ 54 | .pytest_cache/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | db.sqlite3 64 | db.sqlite3-journal 65 | 66 | # Flask stuff: 67 | instance/ 68 | .webassets-cache 69 | 70 | # Scrapy stuff: 71 | .scrapy 72 | 73 | # Sphinx documentation 74 | docs/_build/ 75 | 76 | # PyBuilder 77 | target/ 78 | 79 | # Jupyter Notebook 80 | .ipynb_checkpoints 81 | 82 | # IPython 83 | profile_default/ 84 | ipython_config.py 85 | 86 | # pyenv 87 | .python-version 88 | 89 | # pipenv 90 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 91 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 92 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 93 | # install all needed dependencies. 94 | #Pipfile.lock 95 | 96 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 97 | __pypackages__/ 98 | 99 | # Celery stuff 100 | celerybeat-schedule 101 | celerybeat.pid 102 | 103 | # SageMath parsed files 104 | *.sage.py 105 | 106 | # Environments 107 | .env 108 | .venv 109 | env/ 110 | venv/ 111 | ENV/ 112 | env.bak/ 113 | venv.bak/ 114 | 115 | # Spyder project settings 116 | .spyderproject 117 | .spyproject 118 | 119 | # Rope project settings 120 | .ropeproject 121 | 122 | # mkdocs documentation 123 | /site 124 | 125 | # mypy 126 | .mypy_cache/ 127 | .dmypy.json 128 | dmypy.json 129 | 130 | # Pyre type checker 131 | .pyre/ 132 | --------------------------------------------------------------------------------