Skip to content

Instantly share code, notes, and snippets.

@tanyuan
Last active July 13, 2025 17:06
Show Gist options
  • Save tanyuan/140d70a422200e63d2e3f3c87ed06b26 to your computer and use it in GitHub Desktop.
Save tanyuan/140d70a422200e63d2e3f3c87ed06b26 to your computer and use it in GitHub Desktop.
How to host Otterwiki on Python Anywhere

How to host Otterwiki on Python Anywhere

This is step-by-step to host Otterwiki on Python Anywhere without using docker. This way you have the flexibility to edit the code (CSS, etc) as you like.

Replace all username with your own username.

1. Open a bash console, git clone, and make

Basically following Otterwiki Development:

git clone https://github.com/redimp/otterwiki.git && cd otterwiki
mkdir -p app-data/repository
git init app-data/repository
echo "REPOSITORY='${PWD}/app-data/repository'" >> settings.cfg
echo "SQLALCHEMY_DATABASE_URI='sqlite:///${PWD}/app-data/db.sqlite'" >> settings.cfg
echo "SECRET_KEY='$(echo $RANDOM | md5sum | head -c 16)'" >> settings.cfg
make debug

It will fail to run at the end but it is okay as long as it built.

2. Setup environmental variables

Enable virtual environment for the installation:

source venv/bin/activate
pip install python-dotenv

Create a file .env at /home/username/otterwiki:

FLASK_ENV=production
FLASK_DEBUG=False
FLASK_APP=otterwiki.server
OTTERWIKI_SETTINGS=../settings.cfg 

Reference: PythonAnywhere Environment Variables

3. Create a web app (manual setup)

Set the paths:

  • Source code: /home/username/otterwiki/otterwiki
  • Working directory: /home/username/otterwiki
  • Virtualenv: /home/username/otterwiki/venv

Edit /var/www/username_pythonanywhere_com_wsgi.py, replace everything with the following:

from dotenv import load_dotenv
import os
import sys

project_folder = os.path.expanduser('/home/username/otterwiki')
load_dotenv(os.path.join(project_folder, '.env'))

FLASK_ENV = os.getenv("FLASK_ENV")
FLASK_DEBUG = os.getenv("FLASK_DEBUG")
FLASK_APP = os.getenv("FLASK_APP")
OTTERWIKI_SETTINGS = os.getenv("OTTERWIKI_SETTINGS")

path = '/home/username/otterwiki'
if path not in sys.path:
    sys.path.append(path)

from otterwiki.server import app as application

4. Reload the web app. Hooray!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment