PYTHON 创建WEB服务器
2011-07-09 23:53
447 查看
PYTHON 创建WEB服务器
最近学习python的强大功能,实验一下PYTHON 创建WEB服务器,一下代码非常好使。
最近学习python的强大功能,实验一下PYTHON 创建WEB服务器,一下代码非常好使。
#!/usr/bin/env python #coding=utf-8 #################################################### #文件名:pwebserver.py #创建时间:2008年12月15日 #程序功能:初始化一个web服务器 #文件作者:ixafei #联系方式:ixafei@gmail.com ##################################################### def makeWS(WSDIR = "G:/pp2p/src",WSPORT=9090): import SimpleHTTPServer import SocketServer import os class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler): def translate_path(self, path): os.chdir(WSDIR) return SimpleHTTPServer.SimpleHTTPRequestHandler.translate_path(self,path) try: httpd = SocketServer.TCPServer(("", WSPORT), Handler) print "dir %s serving at port %s"%(repr(WSDIR), WSPORT) httpd.serve_forever() except: pass makeWS()
相关文章推荐
- 使用Python或Node创建简单web服务器和FTP服务器实现文件共享
- python web编程 创建一个web服务器
- django+python创建第一个web项目
- Python实现简易Web服务器
- 创建你的第一个webdriver python代码
- Python web 简单服务器的搭建与运行
- 使用python SimpleHTTPServer 快速搭建Web服务器
- python3+PyQt5 创建网络应用-TCP客户端和TCP服务器
- Python搭建Web服务器,与Ajax交互,接收处理Get和Post请求的简易结构
- 【转】python超简单的web服务器
- 一句Python命令启动一个Web服务器
- WEB服务器:在IIS上实现python CGI
- python多进程web服务器新思路
- Python在web开发中简单服务器的搭建与运行问题
- Python 实现简单 Web 服务器
- python3自带web服务器
- 动态创建 ASP.NET Web 服务器控件模板
- 我的第一个python web开发框架(4)——数据库结构设计与创建
- Web服务器是如何使用JSP来创建网页
- python写web服务器