示例#1
0
def api_raw(hash):
    """
        :param hash: hash of the secret key of a feeder
        :return: returns all feedmoments of the hashed feeder with update-timestamps between the timestamp in the url
        and the timestamp of the next feedmoment (both included)
        """
    feeder = Feeder.get_feeder_from_hash(hash)
    if not feeder is None:
        time = request.args.get('last_update')
        try:
            time = datetime.strptime(time, '%Y-%m-%d %H:%M:%S.%f')
        except:
            time = unix_to_datetime(float(time))
            print(time)
        feedmoment = feeder.get_next_moment()
        moment_time = feedmoment.last_updated
        if moment_time > time:
            # TODO: encrypt
            return str(
                feeder.get_all_moments_updated_between(time,
                                                       moment_time,
                                                       json=False))
        else:
            # TODO: encrypt
            return ''
示例#2
0
def api_raw_unix_nextMoment(hash):
    """
    param: hash of secret key for feeder
    :return: next moment & amount 

    this function serves as a simplified acces point, and disregards all information about update times. It hence does not facilitate caching.
    """
    feeder = Feeder.get_feeder_from_hash(hash)
    if not feeder is None:
        return str([feeder.get_next_moment().get_raw_format()])