This project is the backend for a To Eat List
application. To Eat List
allows managing your home food stock. Please note, this is a pet project, and due to the limited time and resources, it does not always follow best practices.
Setup and serve
pipenv install
Run server
pipenv run flask run
There is a .env.sample file with the environment variables that can be defined.
The CORS config uses the ALLOWED_ORIGINS
env variable to set allowed origins
Use the TEST_DATABASE_URL
env variable to link test db when running in test
env
Run tests using
pipenv run pytest
Create DB
pipenv run flask db_create
Seeding some data
pipenv run flask db_seed
Drop DB
pipenv run flask db_drop
The API is deployed to Heroku
Before you can deploy to heroku add the following files:
Then:
heroku login
if you haven't yet
heroku create <app_name>
or
heroku git:remote -a <existing_app>
finally
git push heroku master
Although this would not be ideal for a scalable service, but for now we can setup a DB manually,when you run:
heroku addons:add heroku-postgresql:hobby-dev
Heroku automatically defines the DATABASE_URL
env varible for the new postgres db.
We needed to install the following packages in our project:
marshmallow-sqlalchemy = "*"
psycopg2-binary
After git push heroku master
, run the create command:
heroku run bash
cd into the Lib
folder and run
flask db_create
If needed, connect to the the production
db in your terminal by changing the env varible DATABASE_URL
to this connection URL:
heroku pg:credentials:url DATABASE