Flask Python Starter Kit from MLH Local Hack Day 2021

What it does

App allows users to authenticate through Github OAuth. User can then view starred projects and search repositories on Github through the app. It also records down all users that have logged in through the app within the PostgreSQL database.

How I built it

Using the starter code and following the tutorial provided here:

Challenges I ran into

  • Tutorial does not always provide all information: The tutorial provides an example for the DATABASE_URL environment variable that did not work for me. I read the code to figure out what it is used for and did some research online to figure out how to connect the PostgreSQL database to the Flask app through SQLAlchemy (understanding the URL format used).
  • Tutorial is not always up-to-date: Apparently, the Github authentication method of using params for the access token has been recently (the last year or so?) depreciated. Now, the header authentication method is required. I printed out the response data and did some online searching before I could figure this one out.
  • Deploying through Heroku: Deployment was tricky as there were several additional steps that needed to be done (more research~). I ended up using Heroku Postgres add-on and Heroku's config vars for the environment variables (hiding secrets for Heroku production).

Accomplishments that I'm proud of

  • Successful deployment on Heroku! []
  • I made two pull requests on updating the depreciated Github authentication method and on improving the docs for better clarity + more information. First time contributing to a public repo/tutorial! :)

What I learned

  • Code structuring: structuring into controllers, models, services folders
  • Connecting Flask application to a PostgreSQL database, through the SQLAlchemy data layer
  • Using Github OAuth, then obtaining and storing the access token through the global session variable

What's next for Flask Starter Kit - Github OAuth [MLH Local Hack Day 2021]

This starter code would be a good base to expand on for Flask + Database + API ideas in the future!

Built With

Share this project: