add format=simple in server

This commit is contained in:
wyy 2014-04-03 04:53:00 -07:00
parent 467fcf8434
commit d791859027
2 changed files with 24 additions and 1 deletions

View File

@ -57,7 +57,25 @@ sudo /etc/init.d/cjserver stop
然后用chrome浏览器打开`http://127.0.0.1:11200/?key=南京市长江大桥`
(用chrome的原因是chrome的默认编码就是utf-8)
或者用命令 `curl "http://127.0.0.1:11200/?key=南京市长江大桥"` (ubuntu中的curl安装命令`sudo apt-get install curl`)
或者用命令 `curl "http://127.0.0.1:11200/?key=南京市长江大桥"` (ubuntu中的curl安装命令`sudo apt-get install curl`)
你可以看到返回的结果如下:(返回结果是json格式)
```
["南京市", "长江大桥"]
```
如果你使用如下调用方式:
```
curl "http://127.0.0.1:11200/?key=南京市长江大桥&format=simple"
```
则返回结果如下:(返回结果按空格隔开)
```
南京市 长江大桥
```
### 卸载

View File

@ -26,6 +26,11 @@ class ReqHandler: public IRequestHandler
httpReq.GET("key", tmp);
URLDecode(tmp, sentence);
_segment.cut(sentence, words);
if(httpReq.GET("format", tmp) && tmp == "simple")
{
join(words.begin(), words.end(), strSnd, " ");
return true;
}
strSnd << words;
return true;
}