python twisted安装_windows python twisted下载 安装 使用

windows:

一、下载地址

http://twistedmatrix.com/trac/wiki/Downloads

Twisted-13.2.0.win-amd64-py2.7.msi

zope.interface-4.1.0-py2.7-win-amd64.egg

pyOpenSSL-0.14.tar.gz   (选择安装)

二、.egg文件安装的方法:

需要先下 http://pypi.python.org/pypi/setuptools 工具

D:\软件\python软件>C:\Python27\Scripts\easy_install.exe D:\软件\python软件\zope.

interface-4.1.0-py2.7-win-amd64.egg

三、检测安装

D:\pywork\test>python

Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win

32

Type "help", "copyright", "credits" or "license" for more information.

>>> import twisted

>>> twisted.__version__

'13.2.0'

>>>

四、应用测试

1、在任意目录下建个文件夹  test

2、在test目录下建立pyweb文件夹

并在pyweb里随便写一个index.html文件

测试示例一、

在test文件夹下写一个server.py

from twisted.internet import reactor

from twisted.web import static, server

resource = static.File("./pyweb")

reactor.listenTCP(8080, server.Site(resource))

reactor.run()

cmd切换到test目录下,

运行: python server.py

访问 http://127.0.0.1:8080/

就可以看见你在index.html里写的东西了。

测试示例二、http 接收参数

运行以下脚本,并访问

from twisted.web import server, resource

from twisted.internet import reactor

from twisted.web import http

class ChildSimple(resource.Resource):

isLeaf=True

def __init__(self, id):

resource.Resource.__init__(self)

# self.id=id

#print self.method

def render_GET(self, request):

return "Hello, No. = visitor!"

class Simple(resource.Resource,http.Request):

def __init__(self):

resource.Resource.__init__(self)

self.putChild("test", self)

def render_GET(self, request):

return "Hello, world!"

def getChild(self, path, request):

print request.args

return ChildSimple(path)

reactor.listenTCP(9990, server.Site(Simple()))

print 123

reactor.run()

http://127.0.0.1:9990?a=1

end!

linux:

下载地址:

http://twistedmatrix.com/Releases/

tar -zxvf Twisted-1.3.0.tar.bz2 tar jxvf Twisted-1.3.0.tar.bz2 cd Twisted-1.3.0 python setup.py install

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值