flask and react deployed on heroku

a onepage react app served by flask & sqlite/postgres db, deployed easily on heroku.

Production ready example

Usage

Local Development

$ git clone...
$ cd <>

DB

sudo -u postgres psql postgres

Server

$ virtualenv -p python3 venv
$ pip install -r requirements.txt
$ gunicorn app:app

Client

$ cd client
$ npm install
$ chmod +x run_dev.sh
$ ./run_dev.sh

To build client app comment out process.env.REACT_APP_USERS_SERVICE_URL and run : npm run build

To check the build directory on a static server :

$ cd build
$ python3 -m http.server

Deployment on heroku

Disable flask-CORS

$ heroku login ...
$ heroku create <your-app-name>
$ heroku addons:add heroku-postgresql:hobby-dev
$ heroku run python
>>> import os
>>> os.environ.get('DATABASE_URL')

copy db_url to your app_config, and then:

$ heroku git:remote <your-app-name>
$ git push heroku master
$ heroku run python
>>> from app import db
>>> db.create_all()
>>> exit()

Resources

  1. static files in flask

  2. python3 virtualenv

  3. react-bootstrap

  4. react-scrollable-anchor

  5. google-maps-react

  6. Sahil Diwan - flask and postgres on heroku

  7. Setting up flask app in heroku with a database

  8. Testeimonials Carousel