Kaili Wang 5a33bfbf48 fix anon score (#67) 2 jaren geleden
..
app 5a33bfbf48 fix anon score (#67) 2 jaren geleden
db_utils a0a3f854f7 Live updating pipeline (#58) 2 jaren geleden
tests a0a3f854f7 Live updating pipeline (#58) 2 jaren geleden
README.md e4f38d5d5d update readme for dev (#15) 3 jaren geleden
__init__.py 7a35f5cf36 initial commit: porting over from private repo. 3 jaren geleden
config.py 7a35f5cf36 initial commit: porting over from private repo. 3 jaren geleden
dump.rdb 716c7c5923 Add react (#10) 3 jaren geleden
init_env.sh 7a35f5cf36 initial commit: porting over from private repo. 3 jaren geleden
requirements.txt e4f38d5d5d update readme for dev (#15) 3 jaren geleden
run.py 7a35f5cf36 initial commit: porting over from private repo. 3 jaren geleden

README.md

Web API through Flask

Before you run the project locally, follow the installation steps below.

After that, do the following:

from the overall project directory:

sh start_redis.sh       (start the redis server)

in a new terminal tab:

cd webapp
python run.py           (run the actual app) 

Note: if it throws an error about ens not being found, do NOT install ens. install/reinstall web3 (pip install web3).

If it throws other import errors, then just pip install {package-name}

Usage + setup

You will need to run for every fresh terminal instance

export FLASK_APP=run.py
export INFURA_ALPHA_ID='your-infura-alpha-id'
export INFURA_ALPHA_SECRET='your-infura-alpha-secret'
source init_env.sh

If you get issues later about webapp.run not being found, then replace run.py with the absolute path of webapp/run.py

Note that you will need to do this even if you did this in the parent directory.

Dependencies

create a venv using python -m venv ./path/to/where/you/want/your/venv

then: source ./{path-to-venv}/bin/activate

then

cd webapp 
pip -r install requirements.txt

Redis installations

sudo apt install redis-server
sudo apt install redis-cli
sudo apt install redis-tools

Flask db setup:

flask db init
flask db migrate
flask db upgrade

other useful commands during development

Database

to update the database (if more / fewer tables exist)

cd webapp/app
rm -rf migrations/  

psql -U tornado                         (open psql cli)
\c tornado;                             (connect to the tornado database)
\dt;                                    (to see current tables) 
drop table {name of table}              (to delete table so that you can repopulate later)
\q                                      (quit)

flask db init
flask db migrate
flask db upgrade

redis

If you made backend changes that change the api response, you'll need to flush redis.

redis-cli -h localhost -p 6380

^ make sure redis-server is running in another terminal tab simultaneously.

if changing front-end code (involving react):

cd webapp/app/static

npm run watch

now, whenever you change and save your code, it will automatically update the running front-end code.