如何使用Python中的CGI编程编写第一个Hello World程序?
第一个CGI程序
一个名为hello.py的CGI脚本保存在/var/www/cgi-bin目录中,并且具有以下内容。在运行CGI程序之前,我们确保使用chmod755hello.pyUNIX命令更改文件的模式以使文件可执行。
示例
#!/usr/bin/python print "Content-type:text/html\r\n\r\n" print '<html>' print '<head>' print '<title>Hello Word - First CGI Program</title>' print '</head>' print '<body>' print '<h2>Hello Word! This is my first CGI program</h2>' print '</body>' print '</html>'
输出结果
如果单击hello.py,则将产生以下输出-
Hello Word! This is my first CGI program
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短