def host_get(hst=None): if settings.app.demo_mode: resp = utils.demo_get_cache() if resp: return utils.jsonify(resp) if hst: resp = host.get_by_id(hst).dict() if settings.app.demo_mode: utils.demo_set_cache(resp) return utils.jsonify(resp) hosts = [] page = flask.request.args.get('page', None) page = int(page) if page else page for hst in host.iter_hosts_dict(page=page): hosts.append(hst) if page is not None: resp = { 'page': page, 'page_total': host.get_host_page_total(), 'hosts': hosts, } else: resp = hosts if settings.app.demo_mode: utils.demo_set_cache(resp) return utils.jsonify(resp)
def host_get(hst=None): if settings.app.demo_mode: resp = utils.demo_get_cache() if resp: return utils.jsonify(resp) if hst: resp = host.get_by_id(hst).dict() if settings.app.demo_mode: utils.demo_set_cache(resp) return utils.jsonify(resp) hosts = [] page = flask.request.args.get('page', None) page = int(page) if page else page for hst in host.iter_hosts_dict(page=page): if settings.app.demo_mode: hst['users_online'] = hst['user_count'] hosts.append(hst) if page is not None: resp = { 'page': page, 'page_total': host.get_host_page_total(), 'hosts': hosts, } else: resp = hosts if settings.app.demo_mode: utils.demo_set_cache(resp) return utils.jsonify(resp)
def host_get(hst=None): if hst: return utils.jsonify(host.get_by_id(hst).dict()) hosts = [] page = flask.request.args.get('page', None) page = int(page) if page else page for hst in host.iter_hosts_dict(page=page): hosts.append(hst) if page is not None: return utils.jsonify({ 'page': page, 'page_total': host.get_host_page_total(), 'hosts': hosts, }) else: return utils.jsonify(hosts)