>网站服务器>服务器租用>广东服务器托管python超简单的we.. 免费发布服务器租用信息
广告
热门浏览

广东服务器托管python超简单的web高防服务器

更新时间:2018-10-09 15:48:42 信息编号:228962312
广东服务器托管python超简单的web高防服务器
1≥ 1台
  • 1.00 元

  • intel

  • 机架式

  • 高防服务器租用,广东服务器托管,WEB高防服务器,单机超级防御

分享

详情介绍

服务项目
高防服务器租用,广东服务器托管,WEB高防服务器,单机超级防御
面向地区
全国
品牌
intel
服务器类型
机架式
CPU类型
I5
内存类型
DDR2
CPU核心
双核
OEM
标配CPU个数
1个
标配硬盘转速
10000转
磁盘阵列
RAID1
货源类别
现货
结构
1U
硬盘容量
500GB
支持内存容量
4GB
质保
一年
大CPU个数
1个
类型
其它

广东服务器托管python超简单的web高防服务器

广东服务器托管python超简单的web高防服务器

高防服务器租用 请联系:锐辉网络--小敏 :.......................2853898501


web1.py
web1.py
Python
#!/usr/bin/python
import SimpleHTTPServer
SimpleHTTPServer.test()

#!/usr/bin/python
import SimpleHTTPServer
SimpleHTTPServer.test()
web2.py

web2.py
Python

#!/usr/bin/python
import SimpleHTTPServer
import SocketServer
import os

PORT = 80
WEBDIR = "f:/python语言学习"

class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def translate_path(self, path):
os.chdir(WEBDIR)
return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self,path)

try:
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "dir %s serving at port %s"%(repr(WEBDIR), PORT)
httpd.serve_forever()
except:pass

#!/usr/bin/python
import SimpleHTTPServer
import SocketServer
import os

PORT = 80
WEBDIR = "f:/python语言学习"
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def translate_path(self, path):
os.chdir(WEBDIR)
return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self,path)
try:
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "dir %s serving at port %s"%(repr(WEBDIR), PORT)
httpd.serve_forever()
except:pass

web3.py , cgi server ,7777端口, 在web3.py执行目录下新建cgi-bin目录 , 在cgi-bin目录写hello.py

web3.py

web3.py
Python

from CGIHTTPServer import CGIHTTPRequestHandler
from BaseHTTPServer import HTTPServer
server_address=('',7777)
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
httpd.serve_forever()
from CGIHTTPServer import CGIHTTPRequestHandler
from BaseHTTPServer import HTTPServer
server_address=('',7777)
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
httpd.serve_forever()

hello.py

hello.py
Python

#!c:/Python24/python.exe
print "HTTP/1.0 200 OK"
print "Content-Type: text/html"
print ""
print "<p>"
print "Hello World!"
print "</p>"
#!c:/Python24/python.exe

print "HTTP/1.0 200 OK"
print "Content-Type: text/html"
print ""
print "<p>"
print "Hello World!"
print "</p>"

以下这些是需要安装了 twisted 才能使用的
web4.py

web4.py
Python

from twisted.web.resource import Resource
from twisted.web import server
from twisted.web import static
from twisted.internet import reactor

class ReStructured( Resource ):
def __init__( self, filename, *a ):
self.rst = open( filename ).read( )

def render( self, request ):
return self.rst
PORT=8888

resource = static.File('/')
resource.processors = { '.html' : ReStructured }
resource.indexNames = [ 'index.html']

reactor.listenTCP(
PORT,
server.Site( resource )
)
reactor.run( )

from twisted.web.resource import Resource
from twisted.web import server
from twisted.web import static
from twisted.internet import reactor
class ReStructured( Resource ):
def __init__( self, filename, *a ):
self.rst = open( filename ).read( )

def render( self, request ):
return self.rst
PORT=8888

resource = static.File('/')
resource.processors = { '.html' : ReStructured }
resource.indexNames = [ 'index.html']

reactor.listenTCP(
PORT,
server.Site( resource )
)
reactor.run( )

web5.py, 这是又是支持cgi的,又是需要twisted模块的,也是需要在cgi-bin目录下执行,上边的hello.py也能用

web5.py
Python

# -*- coding: utf-8 -*-
from twisted.internet import reactor
from twisted.web import static, server, twcgi
from twisted.web.resource import Resource

class Collection(Resource):
def render_GET(self, request):
return "hello world 你好"

root = static.File('./')
root.putChild('', Collection())
root.putChild('img', static.File('./img'))
root.putChild('cgi-bin', twcgi.CGIDirectory('cgi-bin'))
reactor.listenTCP(80, server.Site(root))
reactor.run()
# -*- coding: utf-8 -*-
from twisted.internet import reactor
from twisted.web import static, server, twcgi
from twisted.web.resource import Resource

class Collection(Resource):
def render_GET(self, request):
return "hello world 你好"

root = static.File('./')
root.putChild('', Collection())
root.putChild('img', static.File('./img'))
root.putChild('cgi-bin', twcgi.CGIDirectory('cgi-bin'))
reactor.listenTCP(80, server.Site(root))
reactor.run()
当然,想实现复杂功能还是需要自己搞代码的,只不过想惊叹python的模块集成得太多功能了.
python超简单的web服务器。

东莞市锐辉网络有限公司 6年

  • 高防服务器,服务器托管
  • 高盛科技园北区C座309

———— 认证资质 ————

没有个人认证
企业认证已通过
天眼查未核实
手机认证已通过
没有微信认证

最近来访记录

  • 北京丰台网友用iPhone手机一个月前在百度APP访问了本页

相关推荐产品

留言板

  • 高防服务器租用广东服务器托管WEB高防服务器单机超级防御
  • 价格商品详情商品参数其它
  • 提交留言即代表同意更多商家联系我
东莞市锐辉网络有限公司为你提供的“广东服务器托管python超简单的web高防服务器”详细介绍,包括高防服务器租用价格、型号、图片、厂家等信息。如有需要,请拨打电话:18316411879。不是你想要的产品?点击发布采购需求,让供应商主动联系你。
“广东服务器托管python超简单的web高防服务器”信息由发布人自行提供,其真实性、合法性由发布人负责。交易汇款需谨慎,请注意调查核实。