标签类目:cgi

Python CGI调试的2两种方法

分类:Python第1种:直接输出标准错误

  1. #linuxany_cgi.py
  2. import sys
  3. sys.stderr = sys.stdout
  4.  
  5. def main():
  6.     import cgi
  7.     # ...do the actual work of the CGI...
  8.     # perhaps ending with:
  9.     print template % script_dictionary
  10.  
  11. print "Content-type: text/html\n\n"
  12. main()

继续阅读 »

Python cgi调试的2种方法

分类:PythonFormatting sprintf()-style in Python

  1. print """<html><head>
  2. <title>%s</title>
  3. </head><body>
  4. <h1>Famous irrational numbers</h1>
  5. <dl><dt>Pi</dt>
  6.     <dd>%2.3f</dd>
  7.     <dt>Square-root of 2</dt>
  8.     <dd>%2.3f</dd></dl>
  9. </body></html>""" % ("linuxany.com-website", 3.1415, 1.4142)

继续阅读 »

Python CGI中两种风格的字符串格式化

分类:PythonFormatting sprintf()-style in Python

  1. print """<html><head>
  2. <title>%s</title>
  3. </head><body>
  4. <h1>Famous irrational numbers</h1>
  5. <dl><dt>Pi</dt>
  6.     <dd>%2.3f</dd>
  7.     <dt>Square-root of 2</dt>
  8.     <dd>%2.3f</dd></dl>
  9. </body></html>""" % ("linuxany.com-website", 3.1415, 1.4142)

继续阅读 »

apache CGI程序的简单配置与使用

分类:Apache添加虚拟主机

<virtualhost 127.0.0.1:50001>
</virtualhost>

这里新添加了50001端口来进行监听,所以还需要添加监听端口号

Listen 50001要让程序能正常运行,还得通过配置ScriptAlias来允许服务器在指定的情况下,以CGI方式运行。

<virtualhost 127.0.0.1:50001>
ScriptAlias /cgi-bin/ /usr/local/apache/cgi-bin/
</virtualhost>

所以上述的配置会告诉apache,所以以/cgi-bin/开头的资源都会被映射到/usr/local/apache/cgi-bin/目录下,并被认为是cgi程序。然后重启服务器

继续阅读 »


返回顶部