{% extends base.html %} {% block content %} {% if handler.request.path == '/table' %}

帮助文档

method path description parameters
GET /table/name 展示名为name的表
可选参数如右所述
sort 使用哪个字段排序,默认为插入顺序倒叙
order 顺序还是倒叙,默认为倒叙
page 当前页数,默认为1
size 每一页显示多少项,默认为20
f 当f=json时,返回json格式数据
POST /table/name 新增名为name的表
body为json格式,其字段类型描述如右所述
fields 有哪些字段以及其类型
docs 表示所有文档,为一个list,成员为dict
search 表示为哪些字段提供搜索
mark key哪个字段用于标记,value可取哪些值,unique结果是否唯一
如可选多个值并且docs字段内有值,其必须为list类型
DELETE /table/name 删除名为name的表

用于展示表格或者标注服务

data='{
    "fields": ["id:int", "title:str", "publish_time:datetime", "tag:int"],
    "docs": [{"id": 1, "title":"hello", "publish_time": "2017-01-01 10:00:00" }],
    "search": ["id", "title", "publish_time"],
    "mark": [{"key": "tag", "value": [0, 1, 2], "unique": false}]
}'
curl -XPOST {{ handler.scheme }}://{{ handler.host }}/table/test -d $data
{% if docs %} {% for doc in docs %} {% end %}
name date action
{{ doc.name }} {{ doc.date }}
{% end %} {% else %} {% include search.html %}
{% for field in handler.args.fields %} {% if field not in list(map(lambda x: x['key'], handler.args.marks)) %} {% end %} {% end %} {% for mark in handler.args.marks %} {% end %} {% for entry in entries %} {% for field in handler.args.fields %} {% if field not in list(map(lambda x: x['key'], handler.args.marks)) %} {% end %} {% end %} {% for mark in handler.args.marks %} {% end %} {% end %}
{{ field }}{{ mark['key'] }}
{% raw entry.get(field, 'hello') %} {% for value in mark['value'] %} {% end %}
{% end %} {% end %} {% block js %} {% end %}