Skip to content

Instantly share code, notes, and snippets.

@codersofthedark
Created April 2, 2013 12:49
Show Gist options
  • Save codersofthedark/5291969 to your computer and use it in GitHub Desktop.
Save codersofthedark/5291969 to your computer and use it in GitHub Desktop.
Couchbase and Twisted
from twisted.web import server, resource
from twisted.internet import reactor
from couchbase.client import Couchbase
couchbase = Couchbase("ubuntumartini03:8091", "martini-tag-manager", "")
bucket = couchbase["martini-tag-manager"]
class HelloResource(resource.Resource):
isLeaf = True
def render_GET(self, request):
#query = self.get_argument("pub_id", strip=True)
data = bucket.get("00000001-Top")[2]
result = json.loads(data)
request.setHeader("content-type", "text/plain")
return result['metaTag']
reactor.listenTCP(8080, server.Site(HelloResource()))
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment