Backend for the MSU app. Used by congress members to upload information and documents for students to use.
To run the app, you need the following installed and running:
- Python 3.7+
- PostgreSQL
$ pip install -r requirements.txt
Ensure that the PostgreSQL service is running on your system.
On Windows, search for the 'Services' app, find the service called 'postgresql-*', and click on 'Start'
By default, Postgres is accessed through the superuser 'postgres' with password 'postgres'. If you don't already have such a user, you can connect to the Postgres instance by running psql and then the following commands:
CREATE USER postgres;
ALTER USER postgres PASSWORD 'postgres';
ALTER USER postgres WITH SUPERUSER;
\q
The default configuration under config.py
assumes you have the
msu_dev
and msu_test
databases created, which are used for
development and testing, respectively. You can create them by doing:
$ psql -U postgres
postgres=# Password for user postgres:postgres
postgres=# CREATE DATABASE msu_dev;
postgres=# CREATE DATABASE msu_test;
postgres=# \q
And then migrating both. The flask environment is configured in
.flaskenv
, which is overridden by environment variables.
On Unix:
$ flask db upgrade
$ FLASK_ENV=testing flask db upgrade
On Windows, you'll have to configure the environment variables before running flask:
> flask db upgrade
> set FLASK_ENV=testing
> flask db upgrade
$ flask run
Alternatively, if that doesn't work you can do
$ python -m flask run
python -m pytest
All the configuration for the app is done under config.py
,
which can be accessed through the app's config property:
from flask import current_app
current_app.config['KEY']
The app uses several external services to provide its features, which are configured as follows.
Files are hosted on AWS S3, which is interfaced using boto3. To use boto3, you'll first need to configure your account credentials, as seen on the boto3 documentation.
Then, ensure the following environment variables are set:
S3_BUCKET
: Name of bucket for storing files