Examples of using the micro-credit API in the Python bottle framework _python

Source: Internet
Author: User
Tags cdata xpath

Micro-letter This thing estimated that otaku few unfamiliar, micro-letter after so many years of development finally to the open platform to make a friendly step. Egg pain thought the micro-letter will be a detailed API and other interfaces, excited to apply for the micro-trust platform, and then start looking for a variety of API location ...

Spent nearly one hours, still not found ...

Finally, the use of Google's big kill device, finally found such a link. I have a go, there is no more simple API documentation.

The most incomprehensible is that there is no local development environment support, every time to put in the production environment to debug.

The most gratifying is: the two methods, production environment debugging several times will be finished.

The Python (bottle) version of the code is as follows:

#-*-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 ' I got a 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 ()

 

Demo direct look at the picture:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.