TennessGo-Web
对github.com/z-t-y/tennessgo进行封装,实现Web API接口,网址为tg-web.herokuapp.com
简易文档
由于此Web API非常简单,我觉得就无需详尽的文档了,在此做简单说明即可。
概述
GET方法
样例:
curl https://tg-web.herokuapp.com/api
返回:
{
"description": "处理不规范中文句子的Web API",
"name": "Tennessine-Go API"
}
POST方法
- Content-Type:
application/json
样例:
curl -d '{"to_translate":"发生甚么事了是啥意思"}' https://tg-web.herokuapp.com/api
返回:
{
"to_translate": "发生甚么事了是啥意思",
"translated": "发生甚么事了是什么意思"
}
如果to_translate
为空字符串或不存在,为方便AJAX使用,不会返回异常状态
而会返回
{
"error": "error message", // 是具体报错情况而定
"translated": ""
}
提示:如果想要为Tennessine-Go构建客户端程序,则可以对error是否为空进行判断