如何使用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 好听的元旦简短祝福语