PythonAnywhere Flask Project


How to deploy a small python flash application on PythonAnywhere

Project on Localhost

The project directory name is airtable_gallery, under a parent called titan. I will preserve these names for convenience. It is handy to have a parent direcory for storing notes, debug dumps, backups that don't go into the git repository. A virtual environment tool is used (mkvirtualenv)


Localhost Steps

  • Final testing and cleanup.

  • Save the virtual environment

    pip freeze > requirements.txt
  • Push to a new empty repo (no README) called 'airtable_gallery' at
    git remote add origin
    git push -u origin master

PythonAnywhere Steps

  • My account is gobot. Choose domain for now.

  • Choose Manual Configuration, not Flask because my own directory design.

  • Choose Python 3.6

Web Tab Settings

Source code: /home/gobot/titan/airtable_gallery
Working dir: /home/gobot/titan/airtable_gallery

Path to Virtual env:    /home/gobot/.virtualenvs/airtable_gallery
Static files: /assets/  /home/gobot/titan/airtable_gallery/app/assets

In Bash console

git config --global "Phil Hardaker"
git config --global

# Create base directory only.

mkdir  ~/titan
cd ~/titan

# Pull my repo, brings .git too
git clone

mkvirtualenv --python=/usr/bin/python3.6 airtable_gallery
# Now paths set to virtualenv, see indicator (airtable_gallery)

# Install project libs
cd ~/titan/airtable_gallery
pip install -r requirements.txt

WSGI file

File location:

  ls /var/www/

But just use the Edit link on Web tab. We will include the secret AIRTABLE_API_KEY to be available in the environment.

    import sys
    import os
    os.environ["AIRTABLE_API_KEY"] = "key11111"

    path = '/home/gobot/titan/airtable_gallery/app'
    if path not in sys.path:

    from app import app as application

Web Tab

Click "Reload" after any change to redeploy.