#-*-Coding: UTF-8 -*- From bottle import debug, default_app, run, get, request, post Import 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 ('// content') [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 go ') 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 () |