def index(): entities = Entity.all() dataset_arg = request.args.get('dataset') if dataset_arg is not None: dataset = Dataset.find(dataset_arg) entities = entities.filter_by(dataset=dataset) filter_name = request.args.get('filter_name', '') if len(filter_name): query = '%' + filter_name + '%' entities = entities.filter(Entity.name.ilike(query)) # TODO, other filters. format = request.args.get('format', 'json').lower().strip() if format == 'csv': res = csvify(entities) else: res = query_pager(entities) if arg_bool('download'): fn = dataset_filename(dataset, format) res.headers['Content-Disposition'] = 'attachment; filename=' + fn return res
def index(): entities = Entity.all() dataset_arg = request.args.get("dataset") if dataset_arg is not None: dataset = Dataset.find(dataset_arg) entities = entities.filter_by(dataset=dataset) filter_name = request.args.get("filter_name", "") if len(filter_name): query = "%" + filter_name + "%" entities = entities.filter(Entity.name.ilike(query)) # TODO, other filters. format = request.args.get("format", "json").lower().strip() if format == "csv": res = csvify(entities) else: pager = Pager(entities) res = jsonify(pager.to_dict()) if arg_bool("download"): fn = dataset_filename(dataset, format) res.headers["Content-Disposition"] = "attachment; filename=" + fn return res