A New App in the Works

After all the work leading up to my dissertation defense (yup, I'm a doctor now!) I started working on a new Flask app. I don't want to reveal too much about it yet in case it doesn't work. I will say that writing it has forced me to learn some new tricks in HTML5 and JavaScript. The app centers around a Python module called DejaVu that lets you fingerprint mp3 files and compare those fingerprints with new ones to find probable audio matches. You know, like Shazam or SoundHound.

If I were recording locally I would only have to use Python. But the comparison needs to happen on the server using local data. So I'm having to work with HTML5 to capture audio from the user's microphone and JavaScript to encode the audio, which then gets passed to Python. When the JavaScript finishes encoding the mp3, its POST behavior drops the new file into a folder on the server. The POST behavior in the appropriate view in the Flask script then grabs the mp3 from the folder, fingerprints it, checks for a match, and then returns the nearest match as an argument for the rendered HTML results page.

That is, if there is a closest match to return. I'm almost to the point where I can test whether DejaVu works well in the relevant domain, which has little in common with overproduced pop music. If it works I'll be back in the next few days to report on my success. If not, I'll be back to tell you about how I wasted the week on a huge failure :)


After some trial and error (and Googling) I was able to implement a simple email notification system using Flask-Mail. Check out my code on GitHub if you want to see how I did it.

Whenever someone signs up they get a nice welcome message in their inbox, and I get a notification saying that I have a new user. I also get a notification whenever someone comments on a post. For the welcome message, I log in the new user after adding him or her to the database. That way I can immediately use current_user.name and current_user.email from the Flask-Login module to personalize the messages before leaving the signup function.

I've learned a lot about web app development while turning this into a functional blog. I'm satisfied with the backend for now. My next tasks are mostly cosmetic--it's looking a little bland around here! I also think I should add an About view to give general information about this project and what I hope to learn by continuing to modify it.

Comments! Other Users!

Something went wrong with my database migration script, so I spend a good chunk of the evening fussing with the database. Since I only had two posts it seemed reasonable to destroy the database and start fresh with a new one. The posts below are copies I made just in case the migration didn't work. I should read the documentation for Alembic and try to understand what went wrong before trying that again.

The good news is that I was able to implement all of the features I listed in the earlier post. You can now sign up and post comments if you want. I'm still kind of new to programming, so any constructive criticism or suggestions would be very helpful!

One feature I want but didn't have the time to implement: a welcome email for folks who sign up to write comments. I see that Flask has a mail module, so I don't think it will be too difficult to make that happen. Email authentication would be nice too. That seems like it would be more involved, though. Anyone already know how to pull that off?


I've identified the features I want to add to the blog before I move on to the next part of the course. It should allow other users to sign up for an account, comment on my posts, and edit or delete their comments. Here are some of the practical things I need to do to make this happen:

  • Add a comment class in the model and have relations pointing from users to their comments.
  • Add an owner method to the user class that stores a Boolean value (true for me, false for you).
  • Add a comments table and owner column to the database, then migrate.
  • Add an html template for the signup page, maybe with some boilerplate user agreement. I might skip the agreement for now.
  • Update the home page to only display edit and delete functions for posts if you're me.
  • Update the post template to display the comments for a post.
  • Add a form box for typing comments on the post template. Restrict submission to users who are logged in.
  • Update the metadata for a post to display the number of comments it has received.
  • Update the post template to display metadata for comments (e.g. author name, date posted.)
  • Add edit and delete options in the metadata of comments. These should only appear if the author of the comment is signed in or the current user. The superuser (me) will see a delete option for every comment. Hopefully the fact that there is no guest posting will scare away all but the most dedicated of trolls and I won't have to actually use the delete feature.
  • Add signup link to bottom of login redirect.

I think that's it. This may take me some time, since I've got some important academic stuff coming up next week and will have to put coding on hold for a few days. I'll write more as I go if anything of note happens along the way.


I just deployed my first functional web app (this blogging application) to Heroku.

The app is a python script that generates the html you see using templates that are filled in based on user input. If you're signed in, you get to add, edit, and delete your posts. The python script also manages a PostgreSQL database that houses posts and user information.

I wrote this app as a project for Thinkful's "Programming in Python" course. I plan to update it regularly with posts about my progress as a burgeoning software developer. I also hope to add comment functionality and other bells/whistles to this app in the near future. When I do, I'll tell you what I did and how I did it.