Due to posible version errors if erros occur while installing the requirements files
pip install -r requirements.txtyou may have to remove psycopg2-binary==2.8.4 and manually install the requirements
pip install psycopg2-binary
pip install psycopg2I have also included a post_requirements_manual.md file so you may easily copy all requirements into the terminal
Further information This should be the required procedure to initialize the app
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
createdb warbler
python seed.py
flask runpip freeze > requirements.txtpsqlCREATE DATABASE warbler_test;
CREATE DATABASE "warbler-test";source venv/bin/activate
FLASK_ENV=testing python -m unittest test_message_model.py
FLASK_ENV=testing python -m unittest test_message_views.py
FLASK_ENV=testing python -m unittest test_user_model.py
FLASK_ENV=testing python -m unittest test_user_views.py- Elephantsql.com
- Create 'Tiny Turtle' free instance
- Select region: US-West-1
- copy related URL
to copy local database to Elephant sql run this script in the terminal
pg_dump -O warbler | psql (url you copied here)then to check the database connection
psql (url you copied here)When we deploy an application in production, we will always want to use a server that is production ready and not meant for just development.
pip install gunicornmake sure to run this inside of the venv then update requirements.txt
pip freeze > requirements.txt- Create an account at Render using GitHub
- From dashboard, create a new instance of “Web service”
- Connect to your repository
- Give it a name (this must be globally unique)
- Make sure the start command is
gunicorn app:app - Choose advanced, and enter environmental variables:
- DATABASE_URL: URL from ElephantSQL (change
postgres:→postgresql:) - SECRET_KEY: anything you want (to be secure: long and random)
- PYTHON_VERSION: 3.X.X - whichever version you are using
- DATABASE_URL: URL from ElephantSQL (change
- Choose “Create Web Service”