Skip to main content

Posts about flask (old posts, page 1)

A Hundred Days of Code, Day 042

Second day with the Flask course.

Beginning to realise that Flask is not a monolithic thing, but consists of a lot of moving parts.
Looking forward to learning what they are as I progress along.

Today I learnt how to set my Flask variable, and create an environment, so that I can run Flask consistently without problems.

Miguel also teaches a simple, yet effective way to combat yak shaving.
You know, where all you want is one simple thing, but then that depends on that other thing, which reminds you that you need that third thing and the next thing you know, you’re at the zoo, shaving a yak, all so you can wax your car.
Just don’t do that other thing.
Focus on what you are doing.
If there is something you need, use a dummy. Mock something up.
This is a very real, meta lesson, that I’ll carry with me for the rest of my days.

So I learnt how to return a web page.
And that got tiring really quickly.
Which is when Miguel introduced me to templates.
And I realise why they are needed.
I created a basic template and also learnt about conditionals in the templating language, Jinja and then I called a stop to the day.
More to follow tomorrow.


A Hundred Days of Code, Day 041

Started to very slowly do the Mega Flask Tutorial.
This real world project-cum-tutorial, should let me learn more real-world-esque Python and expand beyond the tiny vocabulary, I have.

Setup my environment today and created a baby flask app.
Even that had something to teach me.
I could not quite wrap my head around decorators, the first time I read about them and this tiny app uses routes in the form of decorators.
Which meant, I had to go read about them and understand them first.

Routes are paths.
And decorators are something (a function/class) that take your existing code and enclose it, whilst giving it extra functionality.

In my case, my code just printed a line.
And the route decorators, in my case, took that code and assigned it to a web page of my choosing.
Right now the home page is assigned to that line.
And if I choose to, I could assign any other url to that same line.
This was hard, but fun.

Looking to do more of this slow steady work over the coming weeks.