Skip to content
A Python Flask project that ciphers English and Al Bhed
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
__pycache__
static
templates
Pipfile
Pipfile.lock
README.md
begin.py

README.md

Al Bhed English Translator

English to Al Bhed, Al Bhed to English translation form.

Al Bhed is a fictional "language" in the game Final Fantasy X.

Though referred to as a language, Al Bhed is actually a cipher.

The Framework

A simple Python Flask app installed on Ubuntu with Nginx, Gunicorn & virtualenv/pipenv.

The project uses the str.maketrans() to generate a cipher.

CSS framework from https://purecss.io, it's nice to use something other than bootstrap once in a while.

Notes

Make sure to use python version 3 for str.maketrans(). It will not work for python 2.

Local Development

pipenv install
pipenv shell
pip install flask

export FLASK_APP=begin.py

pipenv run flask run

deployment

  • Install on a Ubuntu server or something
  • Set up nginx as proxy server listening to port 8000
  • install gunicorn
  • use supervisor to manage gunicorn

required packages

sudo apt-get install nginx supervisor python-pip python-virtualenv gunicorn

in the webservers home directory:

virtualenv -p python3 .env
source .env/bin/activate
pip install flask gunicorn

this creates a virtual environment with python 3 and we install all the packages.

set up Nginx - set as port 8000, remove all else

/etc/nginx/sites-available/albhed.tld:

server {
        location / {
                proxy_pass http://127.0.0.1:8000;
                proxy_set_header Host $host;
                proxy_set_header X-Real_IP $remote_addr;
        }
}

Since gunicorn will run on port 8000, this is what Nginx will look for.

To run gunicorn server:

gunicorn begin:app

the site should now be up

Keep the site up with Supervisor

Create a supervisor file in /etc/supervisor/conf.d/albhed.conf:

[program:albhed]
directory=/home/albhed/albhed/
command=/home/albhed/albhed/env3/bin/gunicorn begin:app -b localhost:8000
autostart=true
autorestart=true
stderr_logfile=/var/log/albhed/albhed.err.log
stdout_logfile=/var/log/albhed/albhed.out.log

check directories are correct, create log files if need be.

to enable config:

sudo supervisorctl reread
sudo service supervisor restart

(need to add reset superviser after site changes.)

to check all monitored apps:

sudo supervisorctl status

working example: http://albhed.webspark.hk/

You can’t perform that action at this time.