Hey party people,
Managed to get a plotly/dash app working on a dreamhost subdomain thanks to a bit of code from Adam’s/Charming Data’s PythonAnywhere deployment video.
The solution was simpler than expected, and is described around the 19:30 mark of the video.
If you’re trying to do this, I’d suggest following the Brett’s Beta" tutorial posted above, with two notes:
-
Make sure the app and venv folders get created in the yoursite.namehere.com directory as opposed to the /home/user/ directory.
-
After installing flask (pip install flask) make sure to install all the other modules and packages your app will require (numpy, plotly, dash, etc.).
The Aropha tutorial covers many of the same steps with a bit more explanation, so it’s worth a read.
Once you’ve gotten the “Hello from Flask” part of the Brett’s Beta tutorial to work, you’re three steps away from having your own app running.
Step1: Edit the passenger_wsgi.py file to say the following. You’ll notice only the last few lines are changed from the tutorial’s:
import sys, os
INTERP = os.path.join(os.environ['HOME'], 'yourwebsite.urlgoeshere.com', 'venv', 'bin', 'python3')
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)
sys.path.append(os.getcwd())
sys.path.append('app')
from routes import app
application = app.server
Step 2: Edit the routes.py file, which will act as your main app file. Take whatever you’ve designed and paste it there.
Step 3: Go back to your ssh connection terminal and restart the server with:
touch tmp/restart.txt
And that’s it, should be up and running. First load takes a bit but after that it’s smooth. I’m sure this is an easy way out, or a non-optimal way of using the flask framework, but hey, website!