2019-12-16 19:46:34 Monday
Recent exposure to stammer word project, try
The bottle with a python library to listen when the server localhost: 8080
The requested data word to be transferred jieba, and returns the result word
1. Install bottle libraries and library jieba
2. Code
. 1 # encoding = UTF. 8- 2 . 3 from Bottle Import route, RUN, Template . 4 Import jieba . 5 . 6 @route ( ' / fenci / <name> ' ) . 7 DEF index (name): . 8 seg_list = jieba.cut (name) # default fine mode . 9 SEG = " , " .join (seg_list) 10 return Template ( ' <B> results:! {} {} result </ B> ' , result = SEG) . 11 12 is RUN (= Host 'localhost', port=8080)
3. Test
D:\server\code\python>python fenci.py Bottle v0.12.18 server starting up (using WSGIRefServer())... Listening on http://localhost:8080/ Hit Ctrl-C to quit.
http: // localhost: 8080 / fenci / Here is the National Library of China Shanghai branch
Results: Here, yes, China, the National Library, Shanghai, branches!
A simple version of the test, the subsequent re-optimization into useful