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.