用Python建立最简单的web服务器
2016-06-22 00:00
861 查看
摘要: 用Python建立最简单的web服务器
用Python建立最简单的web服务器
$ python -m SimpleHTTPServer 8080
支持开发功能的 基础web
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class TestHTTPHandle(BaseHTTPRequestHandler): def do_GET(self): buf = ''' <html> <head><title>Not Found</title> </head> <body> The requested document '%s' was not found. </body> </html> ''' self.protocal_version = "HTTP/1.1" self.send_response(200) self.send_header("Welcome", "Contect") self.end_headers() self.wfile.write(buf) def start_server(): http_server = HTTPServer(('0.0.0.0', 8080), TestHTTPHandle) http_server.serve_forever() start_server()
相关文章推荐
- python定时任务
- python中执行命令行的方法 (二)交互式
- Python--文件
- python的一些函数部分
- Java运行Python脚本的几种方式
- 常用排序算法(Python)
- python的lambda、filter、map、reduce、zip函数
- 在java中调用python方法
- python操作mysql数据库
- Day1 初识Python
- python 调用图像处理类库PIL 时遇到的问题
- pip安装python模块报延时错误的解决方法
- python偏函数应用
- python overview
- Python for循环和else
- Python(七)Socket编程、IO多路复用、SocketServer
- Python 数据科学入门
- Python print 中的逗号小技巧
- python: pandas模块
- Python 深,浅copy