コード例 #1
0
def get_url(shortcode):
    """
    This endpoint method handles the redirect requests,
    routed to the shortcode specific routing url and being
    a GET request.

    The Redirect database model specific methods will handle the logic.

    :param shortcode: The provided shortcode as url parameter.
    :type shortcode: str

    :return: The response with the corresponding url for the provided
        shortcode added to the Location header.
    :rtype: flask.Response

    .. note::
        The Redirect database model specific methods handle the logic
        and exception handling for this endpoint, as the endpoint relies
        heavily on database specific logic.
    .. seealso::
        See for database model related methods: src/models.py
        See for exception related exceptions: src/exceptions.py
    """
    redirect_url = Redirect.redirect(shortcode=shortcode)
    response = jsonify()
    response.status_code = 302
    response.headers['Location'] = redirect_url
    return response
コード例 #2
0
 def test_redirect_in_use_success(self):
     url = Redirect.redirect(shortcode='090909')
     assert url == 'scenario8.com'