Example #1
0
def countTagRoute():
    """ Return svg of count and add 1 to url """
    url = utils.getURL(request)
    if url is None:
        return config.CANNOT_FIND_URL_MESSAGE, 404

    valid_cookie = utils.checkValidCookie(request, url)
    connection = db_connection.get_connection()
    if not valid_cookie:
        db_connection.addView(connection, url)
    count = db_connection.getCount(connection, url)

    return makeSVGRequest(count, url, not valid_cookie, False)
Example #2
0
def countRoute():
    """ Return the count for a url and add 1 to it """
    # Attempt to find any sign of a url, return 404 if we can't find anything
    url = utils.getURL(request)
    if url is None:
        return config.CANNOT_FIND_URL_MESSAGE, 404

    # Get/generate cookie, cleanup views, add a view, get the count and commit changes
    valid_cookie = utils.checkValidCookie(request, url)
    connection = db_connection.get_connection()
    if not valid_cookie:
        db_connection.addView(connection, url)
    count = db_connection.getCount(connection, url)

    return makeTextRequest(count, url, not valid_cookie)
Example #3
0
def countTagRoute():
    """ Return the count for a url and add 1 to it """
    # Attempt to find any sign of a url, return 404 if we can't find anything
    url = utils.getURL(request)

    if not url.startswith("www.jamesleighton.com"):
        return config.CANNOT_FIND_URL_MESSAGE, 404

    if url is None:
        return config.CANNOT_FIND_URL_MESSAGE, 404

    valid_cookie = utils.checkValidCookie(request, url)
    connection = db_connection.get_connection()
    if not valid_cookie:
        db_connection.addView(connection, url)
    count = db_connection.getCount(connection, url)

    return makeSVGRequest(count, url, not valid_cookie)