Unfamiliar Environments: Flask!

Oh boy, what an emotional rollercoaster!

On Thursday afternoon we were divided up into two groups and tasked with creating a Flask backend for our Angular Reddit clone. Say what?! Although I picked up Python back in the day, I couldn’t remember the last time I used it before this week. And none of us in the class had experience with Flask.

It turns out Flask is analogous to Express in Node. Ok, cool. Setup was kind of a hassle, but the first real blocker was database setup. Most of the Flask tutorials that pop up first in searches involve SQLite. We wanted to set it up to use PostgreSQL because, well, that’s what our Node application used. In hindsight, I suppose we could have made the decision to use SQLite instead. In any case, we left class on Thursday thoroughly confused and frustrated because we had spent all afternoon trying to make the database work to no avail.

Friday morning, I started the day with my hopes much higher. Somehow I managed to find the right tutorial for the setup we wanted, and we got the database figured out well before lunch. PHEW!

Next up: routes. It wasn’t immediately clear how to setup routes in their own files/directories, similar to how Express lets you break it all out. Luckily there isn’t an unruly set of routes, so we threw them all in the base server file. What stood out to me in dealing with routes and database calls with Python/Flask, is that there doesn’t appear to be the overhead of worrying about asynchronous calls/database responses. I’m gonna have to read up a bit more to understand what’s going on underneath. Maybe everything is coming in synchronously?? Anyway, things seemed to just kinda work when we were implementing our routes and those didn’t cause us too much pain.

On Thursday afternoon, I left class feeling really defeated. I was disappointed in myself for getting overly frustrated and not being able to get anything to work. I wasn’t feeling very confident as a developer. When we started working on Friday, though, I said “You know what? Let’s just work through and get as much done as we can and not worry too much.” My team agreed that as long as we got a functioning backend, even if we couldn’t figure out how to get it hooked up to our pre-made Angular frontend, we would be OK.

Once the database and routes were all good, we had time to focus on connecting to our frontend. It wasn’t until after the 4:30PM stand down that it actually started to work!!!!! At first, only our header was showing up and we got 404 messages for all the scripts that were required, but nothing felt better in that moment than seeing those 404 messages. All of the prior worries and struggle pains were immediately swept away, I leapt from my seat! We knew it was just a matter of setting up the paths correctly. Had to do some minor tweaking with regards to the filepaths as I mentioned, but other than that, no changes needed to be made to any of our Angular components or services. Adding, editing, deleting posts and comments mostly just…worked! Pretty crazy!!


Next up: we have to deploy it on AWS. We had one group member researching how to do that ahead of time, and although he wasn’t able to get our app running, I’m confident that we can get it deployed with time to spare on Monday. Heck, maybe one or some of us will work on it this weekend.

What I learned: the ease at which I get frustrated is often the biggest impediment to my own progress. I’ve known this for some time, but it keeps rearing its ugly head. Granted, I was already having a lousy day because I had spent all morning trying to figure out why my Swift app wasn’t working. I didn’t do a great job wiping my slate clean and switching gears to work on Flask. No excuses, though! I’m going to see if I can start recognizing early signs of extreme frustration and try to keep it from escalating too quickly.

I also learned about Flask (duh). Overall I don’t think it’s too bad, but I don’t know if I can make an accurate comparison to ExpressJS just yet. I feel like we haphazardly threw stuff together that works and isn’t terribly ugly, but I don’t know if it really adheres to best practices.

And lastly, I learned that I didn’t really have to panic or lose confidence in myself overall. The whole point of Unfamiliar Environments is to see how we adapt and how much progress we can make in a short amount of time. Next time I’ll do better from the start! I feel good about what we’ve accomplished so far, but more work is to be done!