美文网首页
MAC+Apache+Python3+CGI

MAC+Apache+Python3+CGI

作者: xiaodingdang18 | 来源:发表于2018-11-15 20:46 被阅读0次

1、安装apache

2、brew install httpd24

3、vim /usr/local/etc/httpd/httpd.conf

将注释去掉,如下:
<IfModule mpm_prefork_module>
LoadModule cgi_module libexec/mod_cgi.so
</IfModule>
<IfModule !mpm_prefork_module>
LoadModule cgid_module libexec/mod_cgid.so
</IfModule>

4、在/usr/local/var/www/cgi-bin 放入CGI1.py

5、chmod 777 /usr/local/var/www/cgi-bin/CGI1.py

6、apachectl restart

7、http://localhost:9090/cgi-bin/CGI1.py

!/usr/bin/python

-- coding: UTF-8 --

print("Content-type:text/html")
print('')
print('<html>')
print('<head>')
print('<title>Hello</title>')
print('</head>')
print('<body>')
print('<h2>hello CGI 啦啦啦啦啦</h2>')
print('</body>')
print('</html>')

//头一行要加上这两句注释,不然会报语法错误

!/usr/bin/python

-- coding: UTF-8 --

相关文章

网友评论

      本文标题:MAC+Apache+Python3+CGI

      本文链接:https://www.haomeiwen.com/subject/ocsufqtx.html