search

Home  >  Q&A  >  body text

python - Use Mac's built-in Apache server to develop CGI, and directly output plain text in the browser? Solve

httpd.conf file page configuration and installation tutorial
http://blog.csdn.net/dabiaoya...
Step by step
File permissions are as follows

GhostClock:WWW ghostclock$ ls -al Test.py 
-rwxr-xr-x  1 ghostclock  staff  410 May  9 20:40 Test.py
GhostClock:WWW ghostclock$ 

After entering localhost/Test.py in the browser, plain text is printed

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
print "Content-type:text/html"
print                               # 空行,告诉服务器结束头部
print '<html>'
print '<head>'
print '<meta charset="utf-8">'
print '<title>Hello Word - CGI 程序!</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! 第一CGI程序</h2>'
print '</body>'
print '</html>'

I don’t know where my environment is not configured properly, please solve it

ringa_leeringa_lee2764 days ago616

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-18 10:52:34

    Have you added itAddHandler cgi-script .py? Remember to restart apache after adding it

    reply
    0
  • Cancelreply