a little place for me to write things down so I don't forget them

A Quick and Dirty Blog with Flask and Some Other Bits

I've been eyeing Flask for a while. I've bookmarked dozens of blog posts, github repos and documentation pages in anticipation of playing with Flask. Yesterday, I ran into a post on Reddit entitled, Flask is Awesome for Beginners:

Actually, I don't know if it is. But since everyone else seems to be engaged in “that discussion” again I want to friendly remind you that we (the Flask team) are open to suggestions about how to make things more beginner friendly.

If you have suggestions, leave them here or on the feedback website.

I've done a half-dozen projects in Django, one in Tornado and a couple in Having never touched Flask before, I sat down yesterday afternoon, and twenty-four hours later, I've got a fully-functional blog in a single file and 460 lines of code. Not to mention, I built in all the cool features I wanted.


OpenID Authentication: I really didn't feel like dealing with another login and auth system (though flask-peewee makes that pretty easy). So with a couple models, a couple views I've got a super simple auth system that lets me (and others) log in using their Google, AOL or Yahoo account.

Markdown Everywhere: Blog posts and comments get run through markdown with a couple of extensions. The first is which will automatically replace YouTube, Vimeo, etc. links with embedded videos. The second is which will allow me to show you how to fix mdx_video to work with a more recent version of markdown (etree has been moved to util):

def flash_object(url, width, height):
    obj = markdown.util.etree.Element('object')
    obj.set('type', 'application/x-shockwave-flash')
    obj.set('width', width)
    obj.set('height', height)
    obj.set('data', url)
    param = markdown.util.etree.Element('param')
    param.set('name', 'movie')
    param.set('value', url)
    param = markdown.util.etree.Element('param')
    param.set('name', 'allowFullScreen')
    param.set('value', 'true')
    #param = etree.Element('param')
    #param.set('name', 'allowScriptAccess')
    #param.set('value', 'sameDomain')
    return obj

Drag and Drop Uploads: I hate putting images in blog posts. You've either got some overly strict template or some nasty js editor that spews everything with random markup. So a few lines of js combined with jQuery File Upload, and I can just drag an image (or any other file) onto the page, it will be uploaded and thumbnailed and the proper markdown will be inserted right at my cursor.

Max with my socks