2007年3月29日 星期四
Ubuntu下使用Python开发webservices
Python开发web services非常简单容易,在Ubuntu下开发更是得心应手。
安装Python和ZSI
sudo apt-get install python2.4 python-zsi
MyServer.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
from ZSI import dispatch
def getText():
return 'http://www.urlshow.com'
def getTime():
return time.localtime()
print "启动服务..."
dispatch.AsServer(port=3333)
MyClient.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from ZSI.client import Binding
b = Binding(host='localhost', port=3333)
print '%i年,%i月,%i日,%i点,%i分,%i秒'%b.getTime()[:6]
print b.getText()
运行结果
2007年,3月,29日,13点,39分,7秒
http://www.urlshow.com
安装Python和ZSI
sudo apt-get install python2.4 python-zsi
MyServer.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
from ZSI import dispatch
def getText():
return 'http://www.urlshow.com'
def getTime():
return time.localtime()
print "启动服务..."
dispatch.AsServer(port=3333)
MyClient.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from ZSI.client import Binding
b = Binding(host='localhost', port=3333)
print '%i年,%i月,%i日,%i点,%i分,%i秒'%b.getTime()[:6]
print b.getText()
运行结果
2007年,3月,29日,13点,39分,7秒
http://www.urlshow.com
订阅 帖子 [Atom]
