Loading Shopify Posts via Flask on demand. Flask is Amazing.


Flask is really impressing me. It lets me write very clean obvious code.

We are launching a new site, and need a blog ASAP. I figure it would be a pain to migrate blog hosts so I was curious what I can do with Shopify’s blog API.

I was able to..

  • Loop through Shopify’s API until we get all of the blog posts. This takes a long time.
  • Strip the funky HTML
  • Parse HTML / find first image
  • Cache the results for 30 minutes
  • Split into pages of 25 / separate by pages

Some of the recommended caching plugins are just so useful right out of the box. cache.memoize will cache the results of a function for timeout building a cache key out of the function arguments.

cache.cached caches the result of a view. That means I can really easily and fluidly adjust caches as necessary to keep performance high, even though we’re making many requests to Shopify to get the posts themselves.

Check out the gist

I’m impressed.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s