OS: Linux | Note: Details are not missing but it's that they are in my mind
- Make sure You have cors code inside your Flask API's
- Get a Heroku account and install the heroku cli.
- Push code to a GitHub repo
- requirements.txt and Procfile are must
pip freeze > requirements.txt
- Procfile
- More than 1 worker not supported | gives error that got closed for no reason and other bugs
web: gunicorn gettingstarted.wsgi
web: gunicorn -k eventlet -w 1 runner:app
heroku create AppName1
git push heroku master
heroku addons:create heroku-postgresql:hobby-dev
heroku run python # setting up database
heroku config:set STRIPE_API_KEY="ITSaSecretBABE!"
heroku pg:psql # making changes to database | UPDATE users SET admin_status=true WHERE username='admin';
heroku logs --tail
- Running Gunicorn locally: gunicorn --bind 0.0.0.0:8000 app
- When setting up database
from app import * # app is folder inside which I have my models, routes, api, sockets in a systematic format :: Target is-to import db
db.create_all() # Don't worry that you haven't written any PostgreSQL code, it's all done | details in mind, lol
- Requirements.txt (Authentication: JWT :: pyJWT can also be used | Marshmallow for serialization)
Flask
Flask-SQLAlchemy
postgres
eventlet
gunicorn
Flask-SocketIO
flask-cors
flask-heroku
pyjwt==1.4.2 | pyJWT
flask-marshmallow
marshmallow-sqlalchemy
A Useful Guide
Linking an old github repository with already exsistig heroku app | scenario when GitHub name is changed or code is deleted or duplicating code from a repo again
heroku config
heroku pg:reset DATABASE_URL
- You can copy ur older db to new using ps:copy
heroku releases
heroku releases:info v51
heroku rollback v51
heroku git:clone -a APPNAME
git checkout deployID
git reset --hard deployID
web: gunicorn -w 4 -b 0.0.0.0:$PORT -k gevent main:app
web: python wsgi.py runserver 0.0.0.0:4000