A Python and Flask app for managing cafes and users, allowing users to favorite particular cafes and view their locations on a map. Starter code provided by Rithm School. Pair programmed with Mara Greene.
It focuses on:
- many-to-many relationships in SQLAlchemy
- having Flask run JSON API routes
- Jinja templates and validation with WTForms
- MapQuest Static Map API integration
-
Clone this repository and cd into the flask-cafe folder. In order to make the MapQuest API work you need to set an environment variable
MAPQUEST_API_KEY=<your-key> -
Make a virtual environment, install Flask, and add the project dependencies:
python3 -m venv venv
source venv/bin/activate
pip install flask
pip install -r requirements.txt
- Setup and seed the database:
createdb flaskcafe
python seed.py
Seed the DB on Heroku
DATABASE_URL=$(heroku config:get DATABASE_URL -a stephaniesimms-flask-cafe) python seed.py
- Start the server:
MAPQUEST_API_KEY=<your-key> flask run
This will run the app on http://127.0.0.1:5000/
- Create test database:
createdb flaskcafe-test
- Run tests:
python -m unittest -v tests - to run all tests verbosely
python -m unittest -v tests.CafeViewsTestCase - to run tests for a specific model
python -m unittest -v tests.CafeViewsTestCase.test_list - to run a specific test