您当前的位置: 首页 >  服务器

壹小俊

暂无认证

  • 0浏览

    0关注

    885博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

python一个命令开启http服务器

壹小俊 发布时间:2019-03-17 18:24:44 ,浏览量:0

1、python开启http服务器

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  

我喜欢程序员,他们单纯、固执、容易体会到成就感;面对压力,能够挑灯夜战不眠不休;面对困难,能够迎难而上挑战自我。他

们也会感到困惑与傍徨,但每个程序员的心中都有一个比尔盖茨或是乔布斯的梦想“用智慧开创属于自己的事业”。我想说的是,其实我是一个程序员

 

关注
打赏
1664335782
查看更多评论
立即登录/注册

微信扫码登录

0.0719s