2016-05-03 59 views
-2

我有一個關於Python運行問題的問題。 我用Windows命令提示符使用python -m http.server 8000命令設置了一個本地服務器,但是當我在http://localhost:8000/cgi-bin/hello.py上運行我的腳本時,它僅顯示源代碼而不是實際運行腳本。在本地服務器上運行python腳本只顯示源代碼

我使用我在this鏈接上找到的代碼。

#!/usr/bin/python 

print('Content-Type: text/html') 
print() 
print('<html>') 
print('<head><title>Hello from Python</title></head>') 
print('<body>') 
print('<h2>Hello from Python</h2>') 
print('</body></html>') 

我見過幾個人有同樣的問題,但我真的找不到解決方案。 我使用Python 3.5工作

+1

你是用'python -m CGIHTTPServer'開始的嗎?就像在你鏈接的頁面上一樣? – fsp

+0

請按照該頁面上的說明進行操作。不僅僅是其中的一些。 -1 –

+0

[在Python CGI中打印HTML]可能的副本(http://stackoverflow.com/questions/3169781/printing-html-in-python-cgi) – San

回答

1

您應該遵循the documentation。 Python 3的命令是:

python -m http.server --cgi 8000 
+0

謝謝,我只是找不到它。現在它工作了! –

相關問題