Python Engineer

Free Python and Machine Learning Tutorials

Become A Patron and get exclusive content! Get access to ML From Scratch notebooks, join a private Slack channel, get priority response, and more! I really appreciate the support!

Build & Deploy A Python Web App To Automate Twitter | Flask, Heroku, Twitter API & Google Sheets API

17 May 2020

Build & Deploy a Python web app to schedule Tweets. I'm using Flask, Heroku, the Twitter API, and Google Sheets API for this. You can watch how I build this app step by step from zero to deployment! The app can be hosted for free then.

You can find the starting point for this tutorial on GitHub.

Technology we will be using

Flask Quickstart:

Create virtual env

python3 -m venv venv Activate (on Mac): . venv/bin/activate
pip install Flask export FLASK_APP=app/ flask run

Heroku start

heroku login -i heroku create your_app_name

add config vars:

heroku config:set CONSUMER_KEY=xxx heroku config:set CONSUMER_SECRET=xxx heroku config:set ACCESS_TOKEN=xxx heroku config:set ACCESS_SECRET=xxx heroku config:set INTERVAL=1200 heroku config:set DEBUG=0

Scale worker:

heroku ps:scale worker=1

Test locally:

heroku local

Push to Heroku:

git init heroku git:remote -a your_app_name git add . git commit -m "initial commit" git push heroku master

and later your secret.json:

git checkout -b secret-branch --> remove secret.json from *.gitignore* on new branch git add . git commit -m "add credentials" git push heroku secret-branch:master