Configuration settings

I realized today that I need to add a few features to my Flask Casts site and quickly ran into a couple of different issues. One, I never really considered making changes to the site once deployed. Being an extreme newbie shines through once again. During development I used the git features that are built into pycharm to push the project to GitHub. I work off a couple of different machines usually so this made things pretty nice. I could just click a couple buttons to pull the changes and push and done. There were a lot of things I hadn’t considered. One being the secret key needed for flask sessions. At the moment I have a different key on my production code than what is in the repo. I manually changed this via ssh and reloaded my application. This works but now when I want to push or pull to the production server I am getting things a little mixed up.

My fix is to set up an environment variable to hold the key itself… Of course it’s something I’ve never really done before but you learn something new every day.  I am having some difficulty getting this to work and simply don’t have the time to sit down and work on it tonight. An issue for tomorrow I suppose.

Working through the SaaS flask tutorial on Udemy…

I’ve started going through a SaaS application tutorial on Udemy and discovering that the structure of building an application with Flask is very confusing in the early stages. Especially depending on what tools you are using. In this example he is using Docker to contain the app, and this is my first time using Docker. Seems really cool but I will have to work through this tutorial to get a full understanding. One problem I am having with the tutorial is that you aren’t really writing the code as you go, he has everything in sections already written, and he just walks through and explains it. Which isn’t a huge problem but I plan to use this code as a base for what I am going to build later, so I guess I will just use each chapter and step to build my own product. More details on what that is going to be once I am more comfortable. A few things that are new to me:

Prior to working with Flask, I was introduced to web development frameworks through PHP in the mid 2000’s with Codeigniter and CakePHP…which I really didn’t use a lot…but I gained an understanding of the MVC pattern…then I went on to complete a few tutorials on Rails. So the pattern I am familiar with…but the way in which most Flask tutorials and projects are structured seem to be more like Django, in that they are using the MTV pattern. I’ve linked the article above for further reading on my part to get an idea of how to “not get stuck” in the early stages of planning a project because the pattern is there to assist me.

More tutorials…

I challenged myself with a project and set a deadline to have it done by 9/6. It doesn’t look like a lot, but was a learning experience. Now it is time for my next project. I am floating a few ideas around in my head and feel like it may be a good idea to actual make some videos for the Flask Casts site walking through some ideas. I am also looking to complete some more Udemy tutorials, I have 3 that I would like to complete. One of which is dealing with building API’s with Flask, another on building a SaaS site with Flask and also covers some new material such as Docker which I am very interested in learning. I have some that are more on Python itself which I am finding that I have a basic understanding of, but need more intermediate and advanced experience.

Ill post some updates on the SaaS course, because I believe it will be the one that I begin with.

Deployed…a few days earlier than planned.

Turns out deploying the site was much easier than I had expected. For hosting I chose Digital Ocean based on the multitude of recommendations online plus I was able to get a couple of months free by using a referral link.

So far it is great! They have a ton of useful and informative articles to walk you through most anything you are going to do. First, I signed up on the $5 plan and got a droplet set up with Ubuntu 16.04.3. I used a few different articles to get the site off the ground. Starting with this one to get the server set up:

Basically this one walks you through creating a non-root user with sudo privileges, setting up SSH keys etc… then I went on to actually deploy my app…using this article:

This one walks through the process of installing everything and creating a basic flask app, at this step I actually cloned my repository instead…and then modified the rest of the tutorial based on my specific application.

Also had to install MongoDB to get the app to work correctly:

I then add my Domain and set the nameservers with my registrar…added the @, WWW A records to point toward my domain…

Then I set up LetEncrypt for SSL,

All in all it only took about an hour…and it’s online. I did a basic video which I need to improve some of my setup but…my goal was to get this done by 9/6 and it looks like I made it with time to spare.

I am totally new to all of this so if anyone has any suggestions on how I can improve…I am all ears.

Final touches to my Flask Casts before release

I am making the final touches to the site over the weekend. Today the plan is to get the MAJORITY of the site completed and then make a few little front end tweaks before pushing the site live.

Update at 8PM. I basically got it done today.  Now it’s a matter of deployment.

Going to walk through a tutorial on digital ocean.

Solution for long repeat on checkio

I figured I’d share my solution for Long Repeat on Checkio. I got up this morning and had a few moments to solve. Did some research and found the groupby method from Itertools… there was an example online on how to use so I drew largely from that.

[pastacode lang=”python” manual=”from%20itertools%20import%20groupby%0A%0A%0Adef%20long_repeat(line)%3A%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20groups%20%3D%20groupby(line)%0A%20%20%20%20%20%20%20%20result%20%3D%20%5B(k%2C%20sum(1%20for%20_%20in%20v))%20for%20k%2C%20v%20in%20groups%5D%0A%20%20%20%20%20%20%20%20occ%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20for%20_%20in%20result%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20k%2C%20v%20%3D%20_%0A%20%20%20%20%20%20%20%20%20%20%20%20occ.append(v)%0A%20%20%20%20%20%20%20%20return%20max(occ)%0A%20%20%20%20except%3A%0A%20%20%20%20%20%20%20%20return%200%0A%0A%0Aif%20__name__%20%3D%3D%20’__main__’%3A%0A%20%20%20%20%23%20These%20%22asserts%22%20using%20only%20for%20self-checking%20and%20not%20necessary%20for%20auto-testing%0A%20%20%20%20assert%20long_repeat(‘sdsffffse’)%20%3D%3D%204%2C%20%22First%22%0A%20%20%20%20assert%20long_repeat(‘ddvvrwwwrggg’)%20%3D%3D%203%2C%20%22Second%22%0A%20%20%20%20assert%20long_repeat(%22%22)%20%3D%3D%200%0A%20%20%20%20assert%20long_repeat(%22abababaab%22)%20%3D%3D%202%0A%20%20%20%20print(‘%22Run%22%20is%20good.%20How%20is%20%22Check%22%3F’)” message=”” highlight=”” provider=”manual”/]

MongoDB, standard library, considering rolling my own blog again…

As you well know, I started out rolling my own blog and couldn’t finish due to being an extreme n00b. Now that I’ve made fairly significant progress with my FlaskCasts site I am slightly considering transferring all of this over to a strictly Python blog….but….IDK. We will see.

I got hung up on a couple of things tonight trying to get my flask casts site up off of the ground. First off I really got hung up on name vs id in my form fields. Apparently Flasks Request isn’t too fond of having both a name and an ID…and playing around with Bootstrap the ID tag was automatically placed so I was stuck for several minutes…about an hour..kind of sucked. Again…SOMETHING SMALL! But…I just wrote about it…so all the while I kept telling myself IT HAS TO BE SOMETHING SMALL AND STUPID….ALWAYS IS.

[pastacode lang=”python” manual=”%20%20%20%20%40staticmethod%0A%20%20%20%20def%20update(post_id%2C%20title%2C%20content)%3A%0A%20%20%20%20%20%20%20%20mongo.db.posts.update(%7B’_id’%3A%20post_id%7D%2C%20%7B’%24set’%3A%20%7B%22title%22%3A%20title%2C%20%22content%22%3A%20content%7D%7D)” message=”” highlight=”” provider=”manual”/]

Then I ran into an issue trying to update by post…I forgot the $set (loss for a word here) and ran into some issues…luckily solved em all.

Next up…the create method. This one will be a little tricky because Ive designed the site to show posts by the slug for SEO reasons…so I won’t be able to have duplicate slugs in the database. The slugs are generated with the object/Post itself based on the title….however…I’m leaving myself the option of changing the title/content if need be. This is a simple site so…a lot of common functionality really isn’t required but its fun to think through the possibilities.


Lets do some Checkio…

30 minutes later


and it beat me…lol


working on it,…..


Preparing for the future…

Basically all I am doing is focusing on my future, by learning new skills in the present. It’s easy to get sidetracked and think of new and interesting ideas, but staying focused is the key. One of the things I have been doing is browsing Upwork projects to see what people are looking for in developers/projects. I figure if I can sift through the postings and do my best to learn as much as I can about the technologies people are paying for, my chances of being successful when I am ready to bid. When will that be? I plan on trying to roll out several of my own projects as portfolio pieces and build up a solid amount of content and once I can find a project that I am 100% confident I can fit into my schedule and accomplish I will bid. My goal is 1 year.

I’ve also had a few mobile app ideas float through my head, so learning about REST-ful API’s is on the agenda in the coming months.

As far as my FlaskCasts site…I made a few minor adjustments today. Found a couple of minor bugs I need to work out once I get a minute. Plan to work on it quite a bit tomorrow evening.

Thanks for reading!

Learn by doing

It has become clear to me that the best way to learn something new is by getting your hands dirty and working on something. You can follow tutorials and watch someone else code a project, and follow along. You will definitely learn concepts, but the best way to learn this stuff is by tackling something on your own.  What kind of project should I build? You might ask.

I guarantee there is something that you have always thought would be a cool app or idea…even if it is something really small and trivial. Perhaps you just want a basic blog…which is what I am working on with FlaskCasts.

Today I worked out some login functionality using some of the concepts and methodology I picked up from a Udemy course I just took. This kept me from having to use some sort of extension that may provide way more functionality than I need. This also forced me to get my hands dirty and work out little bugs in the code as they came up.

Little bugs can be very frustrating and can somethings be disheartening. You should keep this in mind, from my experience 99% of the bugs you spend a ton of time on are so trivial that when you find them you feel stupid. One thing is for certain, you will likely remember that mistake going forward and will develop your code in such that you will not make the same mistake again. This might be new habits, or a change in the way you think about things….which the latter is most powerful.

For instance today I kept getting a 404 error on my login form…I couldn’t find the reason for the error…I realized that flasks request.form[‘variable’] is looking for the name=”variable” attribute in the form…not id=”variable”….stupid mistake, but I learned something new and will remember this going forward.  A lot of times it’s just small stuff like this that you learn from and in the end will make you a better developer.


I tinkered with the site a little here and there but nothing ground breaking today. I am just slowly piecing it together and hope to release: 9/6/17 with a couple of videos.

I love, it’s a cool  site that provides you with puzzles to solve in Python. Great learning tool. I embarked on The Angles of a Triangle today.

Never was all that great at trig but I love learning python so I tackled this one. Had help from this site:

And a library I found called Triangle Solver… 

Checkio doesn’t support external packages but I was able to dig through the code and pull out what I needed to solve this one.  Here is my solution:

[pastacode lang=”python” manual=”from%20math%20import%20pi%2C%20acos%0A%0A%0Adef%20sss(a%2Cb%2Cc)%3A%0A%20%20%20%20degree%20%3D%20pi%20%2F%20180%0A%20%20%20%20assert%20a%20%2B%20b%20%3E%20c%20and%20b%20%2B%20c%20%3E%20a%20and%20c%20%2B%20a%20%3E%20b%0A%20%20%20%20A%20%3D%20acos((b**2%20%2B%20c**2%20-%20a**2)%20%2F%20(2%20*%20b%20*%20c))%0A%20%20%20%20B%20%3D%20acos((c**2%20%2B%20a**2%20-%20b**2)%20%2F%20(2%20*%20c%20*%20a))%0A%20%20%20%20C%20%3D%20180%20-%20(A%2Fdegree)%20-%20(B%2Fdegree)%0A%20%20%20%20return%20A%2Fdegree%2C%20B%2Fdegree%2C%20C%0A%0A%0Adef%20checkio(a%2C%20b%2C%20c)%3A%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20A%2C%20B%2C%20C%20%3D%20sss(a%2C%20b%2C%20c)%0A%20%20%20%20%20%20%20%20result%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20round(A)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20round(B)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20round(C)%5D%0A%20%20%20%20%20%20%20%20return%20sorted(result)%0A%20%20%20%20except%3A%0A%20%20%20%20%20%20%20%20return%20%5B0%2C%200%2C%200%5D%0A%0A%0A%23These%20%22asserts%22%20using%20only%20for%20self-checking%20and%20not%20necessary%20for%20auto-testing%0Aif%20__name__%20%3D%3D%20’__main__’%3A%0A%20%20%20%20assert%20checkio(4%2C%204%2C%204)%20%3D%3D%20%5B60%2C%2060%2C%2060%5D%2C%20%22All%20sides%20are%20equal%22%0A%20%20%20%20assert%20checkio(3%2C%204%2C%205)%20%3D%3D%20%5B37%2C%2053%2C%2090%5D%2C%20%22Egyptian%20triangle%22%0A%20%20%20%20assert%20checkio(2%2C%202%2C%205)%20%3D%3D%20%5B0%2C%200%2C%200%5D%2C%20%22It’s%20can%20not%20be%20a%20triangle%22%0A%20%20%20%20assert%20checkio(5%2C%204%2C%203)%20%3D%3D%20%5B37%2C%2053%2C%2090%5D” message=”” highlight=”” provider=”manual”/]