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.
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.
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.
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: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
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: https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04
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, https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
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. https://www.flaskcasts.com
I am totally new to all of this so if anyone has any suggestions on how I can improve…I am all ears.
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.
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.
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.
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,…..
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!
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 py.checkio.org, 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. https://py.checkio.org/mission/triangle-angles/
Never was all that great at trig but I love learning python so I tackled this one. Had help from this site: https://www.mathsisfun.com/algebra/trig-solving-sss-triangles.html
And a library I found called Triangle Solver… https://pypi.python.org/pypi/trianglesolver
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: