Skip to content

lusbenjamin/pymoji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βœ¨πŸ“ΈπŸ•Ά Emojivision πŸ•ΆπŸ“Έβœ¨

Basic Flask web application that uses the Google Vision API to replace faces with emoji.

πŸ›  Install

🍺 OS Dependencies

  • Install and update Homebrew if necessary
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew doctor
  • Install dependencies
brew install coreutils pyenv pyenv-virtualenv
  • Add required shims to your bash profile:
# Python shims
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

☁ Google Cloud Platform Deployment Dependencies

  • If deploying via Google Cloud
brew cask install google-cloud-sdk
cd <project-dir>
./gc init
# enter 'pymoji-176318' for project

🐍 Python Environment

pyenv install 2.7.13 # necessary for google cloud sdk
pyenv install 3.6.2 # necessary for pymoji
  • Create new virtual environment
pyenv virtualenv 3.6.2 pymoji
  • Install dependencies
cd <project-dir>
echo 'pymoji' > .python-version
pip install --upgrade pip setuptools
pip install -r requirements.txt

☁ Google Vision Dependency

If you haven't yet, you'll need to install google-cloud-sdk. You may also need to manually and temporarily change your global python version to pyenv global 2.7.13. Make sure .python-version is correctly set to pymoji.

# This will open a browser for you to Oauth
gcloud auth application-default login

Note that this is basically step #2 in this list; automated robots need to use step #1.

🎣 Git Hooks

  • Auomatically run linters before pushing:
cd <project-dir>
./git-pre-push.sh

πŸ“ Sublime

πŸ’» Local Environment

βš™ Initial Configuration

  • Start by cloning a new developer config
cd <project-dir>
cp config.py instance/local_config.py
  • Edit instance/local_config.py as needed. Be sure to set SERVER_NAME=None!
# probably good to at least set these:
DEBUG = True
TESTING = True # also controls local VS google cloud services
# IMPORTANT: when running local dev environment, must override and set to None
SERVER_NAME = None

# optional overrides
MAX_RESULTS = 5
# ...
  • Make sure everything works
cd <project-dir>
./cli build

🌎 Localhost Webserver

  • Open a terminal and run the dev webserver:
cd <project-dir>
./cli runserver

⌨ Command Line Interface

  • HALP.
cd <project-dir>
./cli -?
  • Wat do runserver?
cd <project-dir>
./cli runserver -?
  • Emojivision a file:
cd <project-dir>
./cli runface pymoji/static/uploads/face-input.jpg
  • Emojivision a directory:
cd <project-dir>
./cli rundir pymoji/static/uploads

☁ Deploy to Cloud (Manual)

cd <project-dir>
./gc app deploy --project pymoji-176318 --promote --stop-previous-version