#Flask Project Template For Webfaction Hosting Environment This repository is meant to provide a quick way to spin up Flask applications on Webfaction and is based off of Aaron Presley's blog post. I'll rely heavily on that post for instructions and will only provide instruction where I deviate from his recipe.
The project structure I've employed here is slighly different, but similar enough that if you get stuck along the way, you should refer to his original blog post which is an excellent synthesis of a few snippets floating around out there.
-
Create a new application on Webfaction
-
Setup your application as a website
-
Edit
apache2/conf/httpd.conf
(see Step 3 of post) -
Clone project
cd ~/webapps/project_name
git clone <YOUR PROJECT'S CLONE URL> app
-
Instantiate virtual environment and install dependencies
cd ~/webapps/project_name/app/
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
-
Create
htdocs/index.py
(slightly modified from Step 6)import sys # Active your Virtual Environment, which I'm assuming you've already setup activate_this='/home/username/webapps/application_name/app/venv/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) # Appending our Flask project files sys.path.append('/home/username/webapps/application_name/app') # Launching our app from main import app as application
-
Point your browser to your new webfaction website!
To avoid exposing sensitive config data, I keep a copy of my current config file (with the sensitive data removed) in _config.py