python创建一个最简单http webserver服务器的方法
作者:work24 时间:2021-12-15 03:45:40
本文实例讲述了python创建一个最简单http webserver服务器的方法。分享给大家供大家参考。具体实现方法如下:
import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
Handler = SimpleHTTPRequestHandler
Server = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('127.0.0.1', port)
Handler.protocol_version = Protocol
httpd = Server(server_address, Handler)
print("Serving HTTP")
httpd.serve_forever()
希望本文所述对大家的Python程序设计有所帮助。
标签:python,http服务器
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python设计模式之模板方法模式实例详解
2023-07-21 01:29:19
![](https://img.aspxhome.com/file/2023/4/109404_0s.png)
下一站:HandlerSocket!
2011-04-11 09:02:00
Python设计模式中的状态模式你了解吗
2023-07-14 08:20:28
![](https://img.aspxhome.com/file/2023/2/60962_0s.png)
Python代码使用 Pyftpdlib实现FTP服务器功能
2022-02-11 16:40:55
![](https://img.aspxhome.com/file/2023/7/99617_0s.webp)
python opencv 读取图片 返回图片某像素点的b,g,r值的实现方法
2023-02-24 06:31:23
使用Python实现简单的学生成绩管理系统
2022-04-28 11:33:07
![](https://img.aspxhome.com/file/2023/1/75171_0s.gif)
我的javascript小扎
2008-08-12 13:04:00
tensorflow mnist 数据加载实现并画图效果
2023-10-20 15:07:33
![](https://img.aspxhome.com/file/2023/3/90653_0s.png)
浅谈Python 中的复数问题
2023-04-22 17:02:11
![](https://img.aspxhome.com/file/2023/1/75181_0s.png)
解决PyTorch与CUDA版本不匹配的问题
2023-12-20 14:41:15
![](https://img.aspxhome.com/file/2023/6/92346_0s.jpg)
关于windos10环境下编译python3版pjsua库的问题
2021-06-04 08:12:13
![](https://img.aspxhome.com/file/2023/3/85293_0s.png)
用ajax实现的自动投票的代码
2023-08-24 16:35:07
php延迟静态绑定实例分析
2023-11-23 11:44:57
python如何将图片转换素描画
2022-05-26 23:17:49
![](https://img.aspxhome.com/file/2023/2/91842_0s.png)
快速创建python 虚拟环境
2023-10-04 08:58:31
![](https://img.aspxhome.com/file/2023/9/95379_0s.png)
JSP组件commons-fileupload实现文件上传
2023-07-03 03:16:01
python实现zencart产品数据导入到magento(python导入数据)
2022-06-04 12:34:32
基于Python的身份证验证识别和数据处理详解
2021-04-22 04:43:09
![](https://img.aspxhome.com/file/2023/0/89200_0s.png)
CSS hacks与争议
2007-11-19 12:56:00
![](https://img.aspxhome.com/file/UploadPic/200711/19/20071119125952144s.gif)
基于python3抓取pinpoint应用信息入库
2021-08-05 12:21:02