我在大学学习python。我有一个非常愚蠢的问题。我如何使用python制作网页?如何用python显示网页?
我这样做,并保存为test.py
print "Hello test \n";
print "\n"
print "Just testing \n";
当我去到URL,我得到了相同的输出
print "Hello test \n";
print "\n"
print "Just testing \n";
我真的很困惑。我究竟做错了什么?我的托管与hostgator。在他们的网站上,它说这样做:
#!/usr/bin/python
print "Content-type: text/html\n\n";
print "<html><head>";
print "<title>CGI Test</title>";
print "</head><body>";
print "<p>Test page using Python</p>";
print "</body></html>";
这给了我同样的错误。
1.您需要一个网络服务器,2.将服务器的HTML内容。这是我相信是最简单的方法:http://fragments.turtlemeat.com/pythonwebserver.php – zengr
你必须配置你的网络服务器(例如'lighpttd'或Apache),以便它在你检索你的URL时执行你的Python文件。 –