Example of using API in the Python Bottle framework, pythonbottle
It is estimated that Otaku is not familiar with this thing. After so many years of development, he finally made a friendly step to the open platform. I thought it would have a detailed api and Other interfaces. I was excited to apply for a public platform, and then began to find the location of various Apis ......
It took nearly an hour and still could not be found ......
Finally, I used the Google kill and finally found such a link. I went here. It's no more simple api documentation than that.
What is most incomprehensible is that there is no local development environment support and debugging should be conducted in the production environment every time.
The most gratifying thing is that the production environment debugging is complete several times.
The Python (bottle) version code is as follows:
#-*-Coding: UTF-8-*-from bottle import debug, default_app, run, get, request, postimport sys, OS, time, libxml2dom @ get ('/') def index (): return request. GET. get ('echostr') @ post ('/') def index_post (): for key, value in request. POST. allitems (): doc = libxml2dom. parseString (key) _ to = doc. xpath ('// fromusername') [0]. textContent _ from = doc. xpath ('// tousername') [0]. textContent # _ content = doc. xpath ('// Co Ntent ') [0]. textContent return "" <xml> <ToUserName> <! [CDATA [% s]> </ToUserName> <FromUserName> <! [CDATA [% s]> </FromUserName> <CreateTime> % s </CreateTime> <MsgType> <! [CDATA [text]> </MsgType> <Content> <! [CDATA [% s]> </Content> <FuncFlag> 0 </FuncFlag> </xml> "" % (_ to, _ from, int (time. time (), u'let me know. ') if _ name _ = "_ main _": # Interactive mode debug (True) port = int (sys. argv [1] if len (sys. argv)> 1 else 8888) run (host = '0. 0.0.0 ', port = port, reloader = True) else: # Mod WSGI launch OS. chdir (OS. path. dirname (_ file _) app = default_app ()
The demo directly looks at the figure: