예제 #1
0
파일: web.py 프로젝트: benoitc/qrurl
def info(uid):
    """ display uri infos """
    url = get_url_info(g.redis_conn, uid)
    if not url:
        flask.abort(404)

    mimetypes = request.accept_mimetypes
    if 'application/json' in mimetypes and not mimetypes.accept_html:
        resp = url.update({"ok": True})
        return jsonify(resp)

    return render_template("info.html", url=url, uid=uid, 
            domain=app.config.get('domain', 'http://qru.cc'))
예제 #2
0
파일: consumer.py 프로젝트: benoitc/qrurl
    def handle_message(self, msg):
        kind, uri = msg.split(":", 1)
        
        print uri
        if kind == "URL":
            doc = api.get_url_info(self.conn_redis, uri)
            print "got doc"
        if kind == "CLICK":
            doc = api.get_click(self.conn_redis, uri)

        diff = time.time() - self.last_updated
        if len(self.docs) == 100 or (len(self.docs) > 0 and diff >= 60):
            # we update each 100 docs or each minutes
            self.couch_db.save_docs(self.docs)
            self.docs = []

        if not doc:
            return
        self.docs.append(doc)
        self.last_updated = time.time()