backend code for Ad Observatory
- Setup virtualenv
virtualenv venv -p python3.7 && source venv/bin/activate && pip install --upgrade -r requirements.txt
- copy
.env.example
to.env
and fill in correct values for fields with<PLACEHOLDER>
. - start cloud SQL proxy instructions to install here so that local server can connect to dev database
example cloud SQL proxy command:
./cloud_sql_proxy --instances=<instance name>=tcp:<port for local forwarding>
- set
FB_ADS_DATABASE_PORT
andGOOGLE_ADS_DATABASE_PORT
in.env
to<port for local forwarding>
specified incloud_sql_proxy
command (prior step) - start server:
python -m main
OR to run similar to production:gunicorn -c gunicorn.conf.py -b :5000 main:app
Above command starts server listening on port 5000, and should be accessible at http://localhost:5000/
NOTE: this requires docker installed on your local machine
- Start a redis instance. example docker command
docker run --name myredis -p 6379:6379 -d redis
- Set following vars in
.env
:
REDIS_HOST=localhost
# This should be the port specified when staring the docker container (ex if using arg -p 1234:5678 this will be 1234)
REDIS_PORT=6379
REDIS_CONNECTION_DISABLE_TLS=1
gcloud app deploy --project=<project ID> <app name>.yaml