@Humbert
2019-03-20T07:01:37.000000Z
字数 2392
阅读 583
Method | URL | Header |
---|---|---|
POST | /api/signup/ | None |
POST BODY
{
"username": "string", // 30个英文字符或15个汉字之内
"password": "string", // 30个字符之内
"email": "string" // 30个字符之内
}
Responses
201: Created
{
"msg": "ok"
}
403: Forbidden 用户名或邮箱重复
{
"msg": "username|email duplicated"
// "username duplicated" 或 "email duplicated"
}
Method | URL | Header |
---|---|---|
POST | /api/signin/ | None |
POST BODY
{
"username": "string",
"password": "string"
}
Responses
200: OK
{
"msg": "ok",
"user_id": 1
}
403: Forbidden 用户名或密码错误
{
"msg": "login error"
}
Method | URL | Header |
---|---|---|
GET | /api/myinfo/ | Token |
此处Token直接传user_id即可.
Response
200: OK
{
"avatar": "http://picture.com/",
"score": 100,
"blank_type": "格式", // "粗体" "斜体" "下划线"
}
403: Forbidden 无权限
Method | URL | Header |
---|---|---|
GET | /api/tags/ | Token |
获取所有分类.
Response
{
"tags": [
{
"tag_id": 1,
"tag_name": "string"
},
{
"tag_id": 2,
"tag_name": "string"
},
]
}
Method | URL | Header |
---|---|---|
GET | /api/fragments/ | Token |
Response
200: OK
{
"fragments": [
{
"id": 1,
"title": "string",
"content": "string",
"tags": ["tag1", "tag2", "tag3" ...]
},
{
"id": 2,
"title": "string",
"content": "string",
"tags": ["tag1", "tag2", "tag3" ...]
},
{
"id": 1,
"title": "string",
"content": "string",
"tags": ["tag1", "tag2", "tag3" ...]
},
......
]
}
403: Forbidden
Method | URL | Header |
---|---|---|
GET | /api/fragments/<int:tag_id> / |
Token |
Response
200: OK
{
"fragments": [
{
"id": 1,
"title": "string",
"content": "string",
"tags": ["tag1", "tag2", "tag3" ...]
},
{
"id": 2,
"title": "string",
"content": "string",
"tags": ["tag1", "tag2", "tag3" ...]
},
{
"id": 1,
"title": "string",
"content": "string",
"tags": ["tag1", "tag2", "tag3" ...]
},
......
]
}
403: Forbidden
Method | URL | Header |
---|---|---|
POST | /api/fragments/ | Token |
POST BODY
{
"title": "标题",
"content": "内容内容内容内容内容",
"blanks": [
{
"start_index": 10,
"end_index": 20,
"content": "十个字十个字十个字十"
},
{
"start_index": 30,
"end_index": 40,
"content": "十个字十个字十个字十"
},
... ...
],
"tags": ["tag1", "tag2"... ...]
}
Response
200: OK
{
"msg": "ok"
}
Method | URL | Header |
---|---|---|
PUT | /api/fragments/<int:fragments_id> / |
Token |
POST BODY
{
"title": "标题",
"content": "内容内容内容内容内容",
"blanks": [
{
"start_index": 10,
"end_index": 20,
"content": "十个字十个字十个字十"
},
{
"start_index": 30,
"end_index": 40,
"content": "十个字十个字十个字十"
},
... ...
],
"tags": ["tag1", "tag2"... ...]
}
Response
200: OK
404: Not Found
获取碎片详情之后,前端比较来确定正确与错误
Method | URL | Header |
---|---|---|
GET | /api/fragments/detail/<int:fragments_id> / |
Token |
Response
{
"title": "标题",
"content": "内容内容内容内容内容",
"blanks": [
{
"start_index": 10,
"end_index": 20,
"content": "十个字十个字十个字十"
},
{
"start_index": 30,
"end_index": 40,
"content": "十个字十个字十个字十"
},
... ...
],
"tags": ["tag1", "tag2"... ...]
}
Method | URL | Header |
---|---|---|
POST | /api/user/score/ | Token |
POST DATA
{
"score": 10
}
Response
200: ok
403: Forbidden