This is a brief (always calling three page things brief makes me wonder if I understand the word sometimes.) overview of where things are with the todoList application.
Having served Flask on AWS before I kind of knew what I was in for. That said, I was able to successfully follow these brief instructions for serving Flask on AWS in about five minutes. Currently I have Apache serving a super basic flask “Hello World” application.
In that same folder, though, I have a git repo of the todolist application. I figure that this is a simple process, but occasionally miss the FTP plugin for Sublime Text. I have made a couple of modifications to the imports due to lack of thinking on my part – I generally always test stuff in DreamPie and didn’t think that the path was different with different scopes. Got that sorted out, thankfully.
I installed the flask-script and flask-bootstrap modules – basically because I like the interactive prompt for the application that flask-script provides, and I like things pretty and am lazy so I am going to use bootstrap.
Finally, since I am building this webapp from scratch, I wanted to make sure that I have the suggested package pattern. To help do this I have been rereading the flask documentation on packages. I am not sure yet, but I think that the actual flask application is going to basically just be an interface, so it should live within the interface. Not totally sure yet, but I am working on it.
Between being sick, having a sick wife, the dog’s cancer and how fast it is spreading, having family in town, having other responsibilities, and general adulting I haven’t made a lot of progress recently.
That said, I currently have the AWS server set up and serving a very basic Flask application. I also have git installed, but I will probably write a bash script to auto update the project when I push to the remote.
I have a project at work I am planning on creating, a python script which does most of the work that I do currently when I am not on the phone. We will see how that goes.
In which I bemoan the fact that I started out two days ago thinking “Yay! I’m sick enough that I am going to have to stay home from work. I am going to hack and post updates!” Sadly that did not happen – about 20 minutes after thinking this I passed out. Then yesterday I had the bright idea to go to work and try to make it through the day.
That did not work so well. I made it like 30 minutes, and then left.
I came home and slept. Made it to work today and was looking forward to doing some hacking tonight, but instead I have been updating my LinkedIn profile.
Look, it is silly to have to ssh in just for a new view into a computer you’re already connected to. Enter the app “screen”. It gives you the ability to have views into the computer, and detach and attach these views at your convenience. Let’s say that you want to start a process which freezes your terminal, but you also want to curl the served content. You can start the process, disconnect from that running screen, connect to a new, virgin, view of the computer, and curl from the new screen. After you are done, you can reconnect to the first screen, stop the process, make changes, and then start it all over again.
That is a very brief, very high level overview of screen. If you have not heard of it, I strongly suggest doing some research of your own as it is super handy for anyone who works on remote machines. You can find a pretty good guide of how to work it here. In the future, if that link is gone: I generally find good articles by looking for irissi and screen. One common task is using it as a connection to your irc account, so there are many good guides on how to work them together.
I have created the amazon account, created an EC2 instance with Ubuntu 16.04 running on it. Converted perfectly good pem file to ppk format because I am currently on a windows machine. Installed Python3 and Flask. Created a simple Flask “Hello World” application and served it via the built in testing server. Sadly, because of one of many potential situations I don’t have access to the hosted content from outside of the server, but if I curl 127.0.0.1:5000 I get my expected content.
Tomorrow I will likely set up the app, as it is, inside of a flask application. I will have to do some work to the templates to make sure that useful information is displayed in a meaningful manner.
While the application is tiny I figure that this is the best time to tie everything to the web application. I am going to use Flask hosted on an AWS account for the time being.
I will use an AWS account because it should be really inexpensive (Free for the first year for new accounts, last I checked.) and it allows me to have a virtual machine. I could write it on my home server, however that is no longer serving externally. Plus, if I want to play with the elastic beanstalk later on I already will have an account in place.
I will use Flask because of it’s amazing templating system and easily creatable API endpoints. I have a great book that I lent out, but thankfully I have the Kindle version of it as well. I think that the paperback version is easier to use than a Kindle and briefly considered buying a new one, but then I remembered the Kindle app for Android. Viola! Saved $40 and I don’t have to try to read a programming book on a Kindle.
The application will most likely support users in the future, as well as some sort of user security, but for now getting the application up will be the main goal. Tonight is prepping Amazon and a rehash of Flask.
I created a version two of the database (although it is not actually used in the script, yet, only manually) which includes tags and tag applications. I used a trigger that runs after a successful delete which deletes records of the tag application. That is actually either because of the trigger or the foreign key dependency. Not too sure.
I also created a method that deletes either of the two tables that are created in the upgrade to two. Basically, I had it error out on the second delete statement because of a type, but it had already done the first delete statement. The next time it ran, it errored out because the first statement had completed so there was not a table to delete. I wrapped it in tries because I expect them to be there, but there is a chance they are not.
I finally added methods to interact with tags to my tag interface. Basically everything from getting todo items with the tags to adding, removing, and deleting tags.
I did some basic testing to make sure the trigger statement worked as expected, it did to the basic test. I should probably write a couple of test scripts that run through all of the different functions and how to test them.
I thought this was going to be a no-zero day thing, but it has not due to many reasons. I am still trying to make that a thing, but I am not sure how often I may post depending on the level of home work any new real life job would require. Yeah, also, I like being with my wife a lot, so I choose her over posting here mostly.
Till next time! (Likely tonight, honestly 🙂 )
Sadly due to many recent events (including Thor being diagnosed) I did not give this the attention I want to. That said, this will be a short update because I am upgrading the database. The next version is bringing tags and projects. Projects are going to include dependencies (eg: before I can wash the car I need to buy a car.), so after I update the database I will soon be updating the objects to utilize this functionality.
Eventually I will need to get a site up and hosting it. I will probably create a totally not fake amazon account and serve it using Flask and whateverTheDefaultTemplatingSystemIsCalled. Anyway, quick post: check.
Since I last updated you I have created the basic ability to add a todo item to the todo list and I have written a method to get the todo items out of the database. I went and checked the bobby tables information to make sure that I wouldn’t enable SQL injection before writing the insert statement, and set some defaults to deny attackers entrance through the queries parameters. (Basically I was afraid that someone may try and inject something that ends the LIMIT part and starts a new malicious statement.)
I then created the basic infrastructure needed for the todo list application. A super basic text based interface (It doesn’t loop yet, but it will format and display the todo list items)
I started to create the second version of the database, but I realized I should probably reread Pep 8 – the Python Styling Guide – before I do any more work on the project. I am frankly unsure of naming conventions so have camelcase and underscores everywhere right now.
That’ll likely be another post.
Recently I have been asked a couple of SQL questions, so I decided to brush up on some of it. I was going to talk about mild being things like “CREATE TABLE” or “INSERT INTO”, medium being joins, then hot being this other thing.
I don’t have patience for all of that, so lets get straight into the HOT.
Did you know you can create TRIGGERs in SQLite? Yeah, you can create snippets of SQL that run before or after specified events to specified data. I know this because originally I was interested in adding a last modified column to my data, but could not figure out a way short of me coding it into all of my statements. Not any more! Here is an example of creating a table which will update last modified column, if I understand correctly.
Yeah, I haven’t tested it yet, I found that idea after I commited for the last time tonight. (Maybe/probably) Anyway, hasta la pasta! Be safe and watch for ninjas!