/CommentApp

Simple Firebase + Flask anonymous comment web app. Homework done @ IIC2173 PUC

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

CommentApp

Simple Firebase + Flask anonymous comment web app. Homework done @ IIC2173 PUC. Application deployed at Google Cloud Platform, using a VM Instance, on Ubuntu 18.04.

Stack

Why Flask? The expected application is really simple: an anonymous comment application. The simplest design should have few routes: the comment form (/), a view of the created comments (/comments) and a route to create the comments (/comments/new).

Why GCP? It's free trial and complete status panel made easy to start the development. It's Cloud Shell allowed to try different comments and setup a custom environment really fast. Bad things? Most of the interesting solutions involve working with more GCP services, but I avoid using another machine. I end up using Firebase (I know it's related to Google anyway).

Why Ubuntu 18.04? It's the same version I use on Windows Subsystem for Linux (WSL), on Windows 10, so I'm familiarized with it.

Why Firebase? Fast, easy to setup and free.

Solution

The application is simple. The routes were created with Flask, and the comments were stored using sqlite. Once the solution was deployed, there were problems while saving updates to the file used as database. So, instead of relying in a file (at least one living in the same server) I preferred to store the comments in a Firebase database, using its API through a simple wrapper, Pyrebase.

To be honest, I tried different solutions:

  • Flask + sqlite, on Google App Engine: Didn't work because I was not able to update a file on production (also, wasn't sure if it was running on port 80)
  • Flask + Firebase, on Google App Engine: It worked! But it was weird to work without touching a server. Something was wrong.
  • Flask + Firebase, on Google VM Instance: After a lot of trouble trying to use the right port, it worked ✨

References