如何使用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 教师闺蜜祝福语简短