发布时间:2019-09-22 07:53:49编辑:auto阅读(2177)
python -m SimpleHTTPServer 8080
如果提示错误:
python.exe: No module named SimpleHTTPServer
则试一下命令:
python -m http.server
2、执行py脚本文件,开启cgi映射
python -m http.server --cgi 8000
py代码里添加
header = 'Content-Type: text/html\n'
print(header)
比如/cgi-bin/1.py文件代码:
header = 'Content-Type: text/html\n'
html = 'abc'
print(header)
print(html)
访问http://127.0.0.1:8000/cgi-bin/1.py
可以正常输出abc
Ps:
py代码文件默认目录在cgi-bin或者htbin
http.server官方文档 https://docs.python.org/3/library/http.server.html
上一篇: python基础(3)—— 程序结构
下一篇: 《Python高效开发实战》实战演练——
51712
51373
41804
38576
33054
30069
28736
23733
23645
22013
2228°
2913°
2434°
2383°
2947°
2379°
3186°
5239°
5057°
3610°