A simple Python Flask app on WebFaction
Flask is a popular Python-based micro framework. Here is how to install it on WebFaction.
This is based on the Flask instructions and the WebFaction instructions.
- Log into your WebFaction control panel
- Domains/Websites -> Applications -> Add new application
- Name: FlaskTest
- mod_wsgi
- mod_wsgi / Python 2.7
- (keep port closed)
- Domains/Websites -> Websites
- Click on website
- Add an application -> Reuse an existing application
- Select flasktest, url: http://cm-demo.com/flasktest
- Save the Website (important: this step is easy to miss, I’ve missed it myself a few times)
- ssh into host
- cd webapps/flasktest
- vi setup.sh
- cut and paste script from https://community.webfaction.com/questions/12718/installing-flask
- Change APPNAME and URLPATH (e.g. /foo)
- exit vi (<esc>ZZ)
- sh setup.sh
- Test it: point your browser to <domain>/foo
- This should show “Hello World!”
- Edit webapps/flasktest/flasktest/__index__.py, line:
return “Hello World!”
to return some different text - Refresh page in browser
- Browser should now show the new text
- Set up the static files – make all files in /foo/static static:
- Domains/Websites -> Websites
- Click on website
- Add an application
- Create a new application
- Name: flasktest_static
- Symbolic link
- Symbolic link to static-only app
- Extra info: /home/<user_name>/<webapps/<app>/<app>/static
- Create the static folder
- Create a test page in the new static folder
- Try loading the page in your browser