(self)
return jsonify(result.data), 200
Return data if long url already exists.
Return data if long url already exists.
Return data if long url already exists .
def get(self):
        """Return data if long url already exists."""
        long_url = request.args.get('url')
        is_valid = validate_url(long_url)
        if is_valid is False:
            return jsonify(dict(error='Invalid URL.')), 400
        link = self.manager.get(long_url)
        if self.manager.has_expired():
            return jsonify(dict(error="Link has expired")), 404
        if link is None:
            abort(404)
        result = self.schema.dump(link)
        return jsonify(result.data), 200
def get ( self ) : long_url = request . args . get ( 'url' ) is_valid = validate_url ( long_url ) if is_valid is False : return jsonify ( dict ( error = 'Invalid URL.' ) ) , 400 link = self . manager . get ( long_url ) if self . manager . has_expired ( ) : return jsonify ( dict ( error = "Link has expired" ) ) , 404 if link is None : abort ( 404 ) result = self . schema . dump ( link ) return jsonify ( result . data ) , 200