Fixed threading bug; moved call to get_posts() outside of Flask shenanigans.