zoukankan      html  css  js  c++  java
  • 使用python xmlrpc client & server 来提供metaweblog服务

    server.py

    #encoding=utf-8
    #!/usr/bin/env python
    from SimpleXMLRPCServer import SimpleXMLRPCServer
    import os

    server = SimpleXMLRPCServer(('localhost', 9000))
    # Expose a function with an alternate name
    def list_contents(dir_name):
        return os.listdir(dir_name)
    server.register_function(list_contents, 'dir')

    def get_users_blogs(blogid,user,password):
        return [{'url': 'http://www.cnblogs.com/lexus/', 'blogid': '25231', 'blogName': u'\u6717\u5fd7\u5de5\u4f5c\u5ba4(Langzhi Studio)'}]
    server.register_function(get_users_blogs, 'blogger.getUsersBlogs')

       
    try:
        print 'Use Control-C to exit'
        server.serve_forever()
    except KeyboardInterrupt:
        print 'Exiting'

    client.py

    #encoding=utf-8
    #!/usr/bin/env python
    import xmlrpclib

    #proxy = xmlrpclib.Server('http://www.cnblogs.com/aa/services/metaweblog.aspx')
    proxy = xmlrpclib.Server('http://localhost:9000')
    print proxy.blogger.getUsersBlogs("23451","aa","bb")

    reference:

    http://www.doughellmann.com/PyMOTW/SimpleXMLRPCServer/#module-SimpleXMLRPCServer

    http://docs.python.org/library/simplexmlrpcserver.html

    http://twistedmatrix.com/documents/current/web/howto/xmlrpc.html

    http://www.tutorialspoint.com/xml-rpc/xml_rpc_examples.htm

    http://docs.python.org/library/xmlrpclib.html

    https://github.com/huafengxi/pblog

    http://www.allyourpixel.com/tag/Django/

    http://www.cppblog.com/ronliu/services/metaweblog.aspx

  • 相关阅读:
    ansible plugins 列表
    ansible common modules
    CentOS 7.3降低内核版本为7.2
    ansible ad-hoc 参考
    kafka监控工具kafka-manager
    zookeeper监控之taokeeper
    linux的ulimit各种限制之深入分析
    docker版的zabbix部署
    kubernetes介绍(1)
    部署k8s时容器中ping不通
  • 原文地址:https://www.cnblogs.com/lexus/p/2329145.html
Copyright © 2011-2022 走看看