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

  • 相关阅读:
    51nod 1134 最长递增子序列
    51nod 1135 原根
    51nod 1136 欧拉函数
    51nod 1137 矩阵乘法
    51nod 1174 区间中最大的数
    51nod 1079 中国剩余定理
    51nod 1181 质数中的质数(质数筛法)
    伪共享(False Sharing)和缓存行(Cache Line)
    mybatis 批量 操作数据
    java开发中beancopy比较
  • 原文地址:https://www.cnblogs.com/lexus/p/2329145.html
Copyright © 2011-2022 走看看