fedeisas / recurse-faces

A flashcard app to help you learn the faces of your fellow Recursers!

Home Page:https://faces.recurse.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recurse Faces

Learn the faces of your fellow Recursers!

Heroku set up

This is app is deployed on Heroku:

$ heroku apps:create

To set up your Heroku app, add both the Python and Node buildpacks:

$ heroku buildpacks:add heroku/python
$ heroku buildpacks:add heroku/nodejs

You will also need to set several environment variables.

Three relate to the Recurse Center OAuth API. When you create your OAuth app in your RC account settings, you will need to set the callback to be https://<your_url>/auth/recurse/callback. Once you create it, you will get a CLIENT_ID and CLIENT_SECRET. You will also need to set a randomly chosen password for Flask to encrypt sessions with.

$ heroku config:set \
    CLIENT_CALLBACK=https://<your_url>/auth/recurse/callback
    CLIENT_ID=<your_client_id> \
    CLIENT_SECRET=<your_client_secret> \
    FLASK_SECRET_KEY=$(makepasswd --chars=64) \
    PRODUCTION=True

You will also need to create a database:

$ heroku create heroku-postgresql:hobby-dev

And you'll probably want logs of some sort. I'm using Papertrail:

$ heroku addons:create papertrail:choklad

Then, in theory, it should be a simple git push heroku master!

Local set up

The app is comprised of a Flask back-end and a React front-end.

Front End

You will need to install dependencies:

$ npm install

If you want to do front end development only, you may set the REACT_APP_USE_TEST_DATA variable:

$ REACT_APP_USE_TEST_DATA=true npm run start

If you want to run the front end with the API, set it up as below. The React dev server is configured to proxy the Flask API, so you need only start both (in separate terminals, probably):

$ npm run start

API

You'll need to install the Python dependencies:

$ python3 -m virtualenv --python=python3 venv
$ . venv/bin/activate
(venv)$ pip install -r requirements.txt

Start the Flask API by:

(venv)$ FLASK_APP=faces.py \
  CLIENT_ID=<your_client_id> \
  CLIENT_SECRET=<your_client_secret> \
  DATABASE_URL=postgres://username:password@hostname:port/database \
  DEFAULT_USER=<your_recurse_user_id> \
  python -m flask run

The DATABASE_URL can be any libpq connection string.

Populating the database

First, create the schema:

$ heroku pg:psql < schema.sql

or

$ psql < schema.sql

Then, download the relevant data from the Recurse Center API, and invoke the update script:

(venv)$ python update-data.py \
  <your_database_url> \
  batches.json \
  batch-*.json

Licensed under the AGPL, version 3

About

A flashcard app to help you learn the faces of your fellow Recursers!

https://faces.recurse.com/

License:GNU Affero General Public License v3.0


Languages

Language:JavaScript 46.6%Language:Python 43.1%Language:HTML 5.3%Language:CSS 3.0%Language:Shell 2.0%