我在大學學習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文件。 –