
从该
http.server文档:
CGIHTTPRequestHandler可以通过传递以下--cgi选项在命令行中启用:
$ python3 -m http.server --bind localhost --cgi 8000
将您的脚本放入
cgi_directories:
这是默认
['/cgi-bin', '/htbin']目录并描述了包含CGI脚本的目录。
在浏览器中打开:
$ python -mwebbrowser http://localhost:8000/cgi-bin/hello.py
在哪里
hello.py:
#!/usr/bin/env python3print("Content-Type: text/htmln")print("<!doctype html><title>Hello</title><h2>hello world</h2>")我必须使其在POSIX:上可执行
chmod +x cgi-bin/hello.py。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)