python 搭建简单http服务器方法
by
pxz
发布于: 2015-01-14 所属分类:
工具
服务器
python
标签:
483
<h3 id="h3--simplehttpserver-"><a name="方法一: SimpleHTTPServer方式" class="reference-link"></a><span class="header-link octicon octicon-link"></span>方法一: SimpleHTTPServer方式</h3><pre><code>cd /www/webroot; #切换到网站根目录
python -m SimpleHTTPServer 8080 #启动服务
</code></pre><p>访问方式 : <code>http://127.0.0.1:8080/index.html</code></p>
<p>缺点:不能执行动态python脚本</p>
<h3 id="h3--cgihttpserver-"><a name="方法二: CGIHTTPServer方式" class="reference-link"></a><span class="header-link octicon octicon-link"></span>方法二: CGIHTTPServer方式</h3><pre><code>cd /www/webroot; #切换到网站根目录
python -m CGIHTTPServer 8080 #启动服务
</code></pre><p>访问方式 :<br>静态: <a href="http://127.0.0.1:8080/index.html">http://127.0.0.1:8080/index.html</a><br>动态: <a href="http://127.0.0.1:8080/cgi-bin/index.py">http://127.0.0.1:8080/cgi-bin/index.py</a></p>