使用python xml-rpc client & server 来提供metaweblog服务
2012-01-24 13:33
741 查看
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
#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
相关文章推荐
- python使用SimpleXMLRPCServer实现简单的rpc
- Writing an XML-RPC server or client in ASP.Net: Part 1
- 使用 XML-RPC 为 C++ 应用程序启用 Web 服务
- Writing an XML-RPC server or client in ASP.Net: Part 2
- linux 下 rpc python 实例之使用XML-RPC进行远程文件共享
- 记录一下:使用 python -m SimpleHTTPServer 快速搭建http服务
- linux 下 rpc python 实例之使用XML-RPC进行远程文件共享
- Windows下使用FileZilla[Server+Client]搭建FTP服务
- Python使用TCPServer编写(多线程)Socket服务
- Python thrift rpc TProcessPoolServer 原生的多进程服务模式
- python基础 27章 使用XML_RPC进行文件共享
- 2017-05-23 DBA日记,使用python巧妙分析listener的log.xml,为连接泄漏提供数据支持
- python client使用http post 到server端的代码
- 微服务学习三:springboot与springcloud集成之Eurake的使用(server端,client端)
- Python使用TCPServer编写(多线程)Socket服务
- 使用 XML-RPC 为 C++ 应用程序启用 Web 服务(将 C++ 方法作为服务公开的详细指南)
- 使用 XML-RPC 为 C++ 应用程序启用 Web 服务
- python项目练习八:使用XML-RPC进行远程文件共享
- python client使用 http post 到server端
- python XML_RPC 的使用 - 千月的python linux 系统管理指南学习笔记(22)