python开启http服务

对于不同的版本,python开启http服务的方式略有不同

  1. python<=2.3
python -c "import SimpleHTTPServer as s; s.test();" 8000
  1. python>=2.4
python -m SimpleHTTPServer 8000
  1. python 3.x
python -m http.server 8000

用于搭建http server的模块有如下三种:

  1. BaseHTTPServer:提供基本的Web服务和处理器类,分别是HTTPServer及BaseHTTPRequestHandler;
  2. SimpleHTTPServer:包含执行GET和HEAD请求的SimpleHTTPRequestHandler类;
  3. CGIHTTPServer:包含处理POST请求和执行的CGIHTTPRequestHandler类。

参考

  1. https://www.cnblogs.com/dggsec/p/9219282.html
  2. https://www.cnblogs.com/sangern/archive/2017/11/03/7777601.html
posted @ 2020-12-19 16:48  baishengguan  阅读(2480)  评论(0编辑  收藏  举报