Deployment: The Next Big Batch of Knowledge After Flask

Deployment: The Next Big Batch of Knowledge After Flask

I’ve begun thinking about how to deploy my app. It would have been easy as a one-pager, but my app has a PostgreSQL database, and it is a social networking site, which means I should prepare for lots and lots of users (assuming people pick it up at all).

Rooting around in this direction turned up this helpful video that tells you about different ways to host your app. It also turned up the idea of “workers”. Heroku and DigitalOcean use workers. What are these? I don’t know yet. Of course there are definitions, as usual. But definitions try to be one-stop shops and catch-all solutions, and in catering to everyone, they cater to no one at all. Ok, I exaggerate. They cater to some. Dictionaries do a pretty decent job although they don’t tell you about nuances, connotations, and other baggage that comes with words.

While researching workers and deployment, I realised that I have to look at sharding, and possibly logical sharding in particular. Also connection pools, database caching, clustering, cloud formation, load balancing, docker/virtualisation, and batching writes to the database. In short, it seems, I have to learn some devops.

We meet again, prong of epistemology. To go from Flask to deployment means learning a whole critical bunch of things.

The bad thing is, I don’t know how much I should know about devops, so I’m groping around in the dark, and groping around for all kinds of different things. To mix two idioms, I’m a drowning man in the dark clutching at straws. The good thing, I suppose, is that I think I know the primary question here: how many requests can a worker handle? It’s a surprisingly hard question to answer, and I have to answer it so I know if the cheapest plan on DigitalOcean is suitable for a starting social networking web app. I’ll root around some more.

Deployment also made me think about marketing, which led me to this video, which reminded me that I have to cite open source code, which means I have to review all my code and try to remember where each part of it came from if I didn’t write it myself.

At the same time, I’ve learnt and exercised enough Flask to know that I should pick up Django and rebuild the entire app in it, and that I should also learn JavaScript, because a lot of interactions, like socketio, depends on it.

Does the prong of epistemology become larger and larger as knowledge increments? At this point, I should be working in a team with proper front end and back end developers and designers, right? But with only basic Python, Flask, and SQL under my belt, what team roughing it out in the savage wilderness of live business operations would want me? “Not good enough”, that old refrain.

But, hey, the only way forward is forward.

What is Model-View-Controller (MVC)

What is Model-View-Controller (MVC)

I was totally confused over how to use flask-security, and researching that made me super confused about sessions vs. cookies vs. tokens, and researching that brought me to the topic of the model-view-controller (MVC). Long story short, I found a pretty good video that introduces the paradigm:

After watching it, I realised I could reduce my code by maybe 90% if I abstracted away huge repetitive bunches of it. I knew this in the back of my mind before but was too caught up learning the basic basics to think about it clearly. Anyway, after watching a few more videos, I think this is one of the better introductions. It provides a brief enough history that segues smoothly into contemporary practice.

I’m still completely baffled with flask-security and slightly more clear about sessions-cookies-tokens. RTFM not working, especially for flask-security.

Quick Word on Jobs

Quick Word on Jobs

I picked code up in part to get a better paying job than anything on offer in the arts. Now I have Python, Flask, and SQL with me. However, after going through job sites for a few days, I’ve discovered that most jobs are for front end developers with HTML5, CSS, and Javascript.

There is a lot of demand for Javascript using AngularJS, React, NodeJS, etc. So, the fastest way to get a job is to pick up front end web dev/design skills.

If you stick with Python and want to do some back end work, you’ll need Django, and NoSQL, typically MongoDB. Not Flask. Exceedingly few hiring companies use Flask.

Ruby on Rails appears quite a bit too. Also a lot of demand for UI/UX. But that floats into a more distant skill set.

Attempting to Learn Flask, Part 3

Attempting to Learn Flask, Part 3

I should close the loop on this series. Part 1 and Part 2, if you’re interested.

The conclusion is, I haven’t mastered it, but I’ve definitely figured out the basics. I thought I’d need to learn more from CS350 for some time before getting here. Instead I found myself going back to just two of the videos in Charles Severance’s “Using Databases with Python” several times and jogging memory with code I’d worked with during that course. I’m forgetful so it was great to have his videos on hand. I also spent a lot of time googling, reading, and YouTubing tutorials.

Basically, I had to draw from everywhere at this point, and the range was really, really wide.

The happy news is, I can now:

  • Use Python to do magic on the back end
  • Use Flask to deliver magic to the front end
  • Use SQLite3 and/or PostgreSQL to handle data (Create, Read, Update, Delete)
  • Doll up my web app a little bit with Bootstrap

I’ve made a couple of apps already:

One uses Python to concatenate randomly selected strings from various lists to form grammatically correct English sentences and then displays a new one in the middle of a webpage at regular intervals.

The other draws from the IMDB database, banishes all USA and Western European films, randomly picks 10 from the rest of the world, and displays them along with their trailers from YouTube. This one was not so trivial for me. There was a lot of junk data in the IMDB database to clean up, and I had to work out how to scrape YouTube to embed the trailers on my site.

So, as of early 2017, I can verify that my proposed path of least resistance for learning how to build a web app from scratch is a pretty decent strategy.

I can’t say if it’ll continue this way. Already there are certain things that are falling into doubt. For instance, CS350 leverages AngularJS a little bit to do Flask stuff, and in the course of reading all the other sources I found out that there is a lot of uncertainty surrounding the future of AngularJS right now. That particular case is not terribly important. Just a small example. We can use other JS frameworks anyway.

What’s next for me? I’m going to build up that film site of mine. Add users to it, work on some formulae running in the back end. Get more familiar with PostgreSQL. Get a better handle on how to mash Flask up with Bootstrap. And then maybe learn Cordova next year to build mobile apps.

Coding is great fun, especially since I use it to engage real world problems. For example, the winner-takes-all effect. Films from USA and Western Europe, and especially from Hollywood, saturate almost every single one of our media environments. My film site bans all USA and Western European films in order to allow the diversity of the rest of the world’s film heritage to come to the fore. Turns out, it’s wonderful. Using it, I discovered amazing, beautiful films from Azerbaijan, Indonesia, Malaysia, Turkey, and elsewhere. I think there was even one from Antigua and Barbados. It’s not ready for the public yet, but I hope to put it up somewhere just for show-and-tell soon.

Another big reason that drove my learning was the oppressive pecuniary pressures in the art world. I wonder if I’m ready for an entry level/junior position yet. I have no idea. Time to try looking around for a job now as well, I guess. At the very least, I’ll get a better idea of what the world wants.

+1 to Digital Literacy

+1 to Digital Literacy

I stumbled into an idle moment and used it to ponder digital literacy. I’ll summarise the Wikipedia link’s summary as the abilities to:

  • “Deduce information from visuals”
  • Create remixes
  • Navigate the non-linearity of the web
  • Find info online and be critical about it
  • Not be an asshole online

I know my summary is not perfect, but neither is the original. I think mine’s more precise. I mean, “don’t be an asshole”. That’s pretty damn clear, right?

Anyway, I think we should add one more. Admittedly, it’s a high-hanging fruit, but I think it’s increasingly important:

  • Find solutions to coding problems even if they are someone else’s script on Stack Overflow that you don’t fully understand.
Attempting to Learn Flask, Part 1

Attempting to Learn Flask, Part 1

I think this might be a series on how I learn Flask. I don’t know if I’ll succeed or fail yet at learning it. I’ll try and track my progress or the lack of it, and hope I don’t run out of steam.

So, I’ve been trying to learn the framework for a while now. The first time I tried was two or three years ago when I first started Python. As you might guess, it was totally the wrong time to start. Now I have a better handle on Python, and I thought about a week or so ago that I’d try again.

Deciding on Flask and Not Django or Bottle or Whatever Else

As it happened with the first time, googling turned up a lot of “should I learn Flask or Django” results and I wavered between the two, and installed both, and then once again decided to focus on Flask.

The decision isn’t that simple to make because lots of people say different things, but I’ll boil them down to two main factions.

One faction says to learn Django because it is sort of standardised. It’s like a set meal. You get burger, fries, soft drink, all together in a sensible, familiar package. As a result, it is also complicated and has a steep learning curve. But, community support is waaaaaaaaaaaaaaaay better than Flask’s! That counts for a lot.

The other faction says to learn Flask because it’s flexible and easier to learn. That means, though, that it’s not like a set meal at all. What it looks like is someone giving you all the raw ingredients of the meal and you have to put it all together yourself. So, you have to learn how to build a burger, and then how to make fries just the way you like, and then the soft drink. People say it’s not that hard, but the people who say that seem to mainly be experts, or those with computing backgrounds, or those with money for boot camps and advisors and teachers. Obviously, it’s not hard for them. Plus, community support is very thin compared to Django’s.

There are other factions, but these are generally the two loudest voices. After a lot of going back-and-forth, deciding, re-deciding, indecision, paralysis, doubt, existential crisis, I settled on Flask because a few people said it’ll be easier to learn Django after Flask. And more importantly, I needed to focus somewhere, and it might be easier to start with what other people claim is easier.


Once beginners start asking questions like, how do we use Python on the web, the answer is bound to be: learn a framework. Remember, at this point, beginners haven’t much of an inkling what Flask is, or even what a web framework is. Everything we read about frameworks online seems to make sense, but only in a sort of hazy, somewhat figurative manner. In other words, it’s likely that experts think they’ve explained it clearly, and beginners think they sort of understand, but there’s a massive gap between the two, and few people see it. Nonetheless, the only way is forward, right?

But the jump from basic/intermediate Python to learning a framework like Flask is HUGE. This will become very apparent when beginners start on the tutorial everyone suggests: Miguel Grinberg’s Mega Flask Tutorial.

This tutorial is spectacularly bad for beginners.

The tutorial doesn’t explain a lot of things, including precisely where Python code connects with its equivalents in the HTML templates. You might say that should be obvious. But it’s obvious for people with a much larger store of knowledge than beginners.

At the same time, the tutorial involves a lot of code connected to each other across many files, in ways that we cannot understand at a glance. Some functions require ostensibly unrelated code inserted into,,, and one or two others. That’s super confusing for beginners.

By the time we reach the part where we write the login page, we give up. Especially because at that point, we have to decide between the chapter from the older tutorial, and the newer one on OAuth that isn’t very clearly connected to the older tutorial. And if we screw either up, we don’t know how to continue with the rest of the mega tutorial.

It Gets Cloudier

At that point, we start looking for other tutorials. A bunch of these want us to start on Droplet (we have to pay for it), Heroku, or other similar services. Only here do we usually get the first mentions of Flask being problematic on Windows, and we’re not sure what that means.

So, we’re stuck. We don’t want to pay for Droplet. And we are scared that if we go with Heroku, we might go off on another difficult tangent with more difficult stuff to learn. We begin to wonder if there’s another tutorial, or if there are ways to work around this.

What do we do next? I don’t quite know yet.

How to Learn Flask

Evidently, there is a big portion of knowledge missing between basic/intermediate Python and Flask. But I don’t know what it is and nobody seems to proffer good estimates. So, I’m going to try two methods people have intimated in the usual overly optimistic terms. “Just do it!” doesn’t cut it, guys.

The first is the project-based method: I know I want to build a chat website, and I have a rough design for it. I know I want to have some development for ecommerce under my belt so I can build a career from it. So it makes sense to start with these two.

The second is to try and break up Flask into small and manageable parts and learn those parts. This is somewhat problematic. People say you can do anything with Flask. That means we don’t know where to begin. It’s like saying, you can do anything you want, so what do you want to do? Well, I want to solve poverty. Maybe I want world peace too. But what are the small tiny manageable parts to those problems? It might be impossible to see. We might get there by iterating through lots and lots of smaller and smaller problems though.

You see how unhelpful it is as a pedagogical guide to tell beginners you can do anything with Flask and then send them to difficult tutorials?

In part 2, if there is a part 2, I will talk about how I got on with this.