Deploy a Python Dash App in 15 minutes
Tags: Programming, Python, Web Hosting, Dash, Deployment

My dash app online — see more at blmjusticeapp.co.uk

How to get your Dash app online in 7 very straightforward steps

You’ve built your app, it’s working great when you run it on your own machine, but now you want to quite literally say ‘hello world’.

Well, you’ve come to the right place.

The Seven Stages of Deployment

Create a paid account at pythonanywhere.com. Buy the domain name you’re interested in at godaddy.com. Clone your repository into a bash console on pythonanywhere.com. Edit your WSGI file (web server gateway interface, easier to say WSGI right?). Point pythonanywhere.com to the domain name you bought. Change your CNAME record at godaddy.com. Set up domain forwarding.

Skip to the Fourth Bit

I’m going to assume you can do steps one to three on your own and also like this song.

In your pythonanywhere.com account, hit the web tab and in the code section, specify the directory the source code was in your bash console where you cloned the github repository. This should also be the working directory.

Next, click the link to your WSGI file. In that file, uncomment the specified section — for me this was lines 107–12.

How your WSGI.py file should look

Point Towards a Custom Domain

Back in the web tab, hit the add a new web app button and then add in the domain name you’ve bought — it’s important this is www.yourdomain.com not yourdomain.com.

If you’ve already got the web app up and running, then click the pencil to edit it fom yourusername.pythonanywhere.com to www.yourdomain.com.

If you get stuck on any of this check out this help article!

Configure your Domain

Next, you need to edit the CNAME record. Hit manage DNS on your website in the godaddy panel and then you need to edit the record circled blue in the image below.

How to edit the CNAME record on godaddy.com

In the name column, put www and then in the value column put the value in the DNS setup section of the web tab from pythonanywhere.com. It’ll be in the format webapp-XXXXXX.pythonanywhere.com.

Where to find the DNS information on python anywhere.com

Domain Forwarding

By this point, everything’s set up so that if you type in www.yourdomain.com to a browser — after reloading the site on pythonanywhere.com — that it should work.

But if you type in yourdomain.com it won’t work! So how do you fix that?

To do this, got back to the manage DNS section for your website on godaddy.com and then look for the forwarding tab in the bottom right of the godaddy page.

There, edit the domain value so it says https://www.yourdomain.com. And that’s it!

Remember, DNS changes take quite a while to propagate across the world wide web so it may take a few days for these changes to kick in. So don’t jump to the conclusion that you’ve made a mistake until time has proven you wrong!

Debugging

If any of this goes wrong, check the logs on pythonanywhere.com. You can find these by navigating down the web tab and looking at the log files section. These will almost definitely tell you what’s wrong.

If you’re looking for solutions, I highly recommend checking out the pythonanywhere guidelines. You can search for this by googling:

site:pythonanywhere.com your error message goes here

Don’t Forget Security!

Last but very not least, put some basic security measures in place before sharing your website with everyone.

First, make sure that in your app.py file for your Dash app, it says debug=False at the end not True!

Back on the web tab in pythonanywhere.com, switch the force https slider to on and select the auto renewed let’s encrypt certificate under the HTTPS certificate radio items.

As an added bonus, this will also mean no-one gets an error message saying your website isn’t safe and you could be stealing the information.

It’s also worth making sure your registration information is private on godaddy unless you particularly want the world to know who’s hosting your website.