Pure Gangsters, Tweet, Tweet

I always like to warn my dear non-techy blogger friends when something technical is coming their way so that they can go onto reading something else. This is one of those times.

In this post, I want to show you how to get your Twitter tweet button count to increment and display properly on your web page.  In this case, I’m using Google app engine’s python implementation, but this could apply for you on a different tech stack.

Generally this isn’t going to be an issue, but you never know, so since I had taken the trouble to do this, I hope it helps someone out one day if they stumble across it in a search engine.

I propped up my stellar gangster kids and tweeted it, but noticed my tweet count didn't increment up. What to do?

I propped up my stellar gangster kids and tweeted it, but noticed my tweet count didn’t increment up. What to do?

I tweeted this picture from proppitup.com.  When I tweeted it, I expected my tweet count to go up by one. From zero to one to be exact. But it didn’t, it just stayed at zero. It could have been cached or any number of things, but I suspected not. Just a hunch. I was right.

The problem was that my server-side code wasn’t properly handling head() requests. I realized I’d need to when I stumbled across this note from Twitter that indicated it was required.

So using curl, here’s what it looked like before. Bad error 405.


So I implemented a quick head() method to see if that was the culprit.

def head(self):
    #this allows twitter callback to work

And here’s what it looked like afterwards.


And what do you know, it worked. My twitter propp count just went up by one. Success!


Super Simple Web Server

Netcat and various other utilities make it so easy to run a simple web server on your machine, but so does Python.

Here’s how you can run it on a Windows machine, but works quite well on Linux too (or Cygwin).

C:\>python -m SimpleHTTPServer
Serving HTTP on port 8000 ...

Now just point your browser here and you’ll see a list of everything served up from that directory. It can also be served up using your IP address and accessed from another machine on the same network.

Google Memcache Is Super Simple

I think Google as a company tries to make everything simple. I love how easy they make caching integration with their platform.

As a simple example, let’s just say you want to cache the home page to your web site for 24 hours.  If your home page doesn’t change often, but is rather intensive to load when someone asks for it, caching it will speed things up pretty dramatically for anyone that accesses it later.

In this case, the previously rendered HTML is loaded from cache if available.  Otherwise, the HTML is rendered from a Jinja template, stored in cache for the next time and then provided.  Simple.

from google.appengine.api import memcache

if memcache.get('yourindexpage'):



template = jinja_environment.get_template('/index.html')

renderedhtml = template.render()

memcache.set('yourindexpage', renderedhtml, 86400)