[英]How can I solve to run my python code run localy?
我已經安裝了 python 3.7 版本。 當我在命令中運行時,它的效果很好。 但是當我嘗試運行 http.server 8000 然后瀏覽 url 然后只顯示我的 index.py 代碼而不是像 web 頁面這樣的運行。
對此有任何想法。
我確實更改了 httpd.cong 文件 1。
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm index.py
</IfModule>
也請檢查我的代碼
#!C:\Users\admin\AppData\Local\Programs\Python\Python37\python.exe
print('sarvesh')
#print(mycursor.rowcount, "record inserted.")
所以請告訴我。
您是否嘗試放入 cgi-bin 文件夾? 你能測試一下以確保你的安裝沒問題嗎? 你在使用任何放大器嗎? (xampp,wamp)
試試這個:創建一個名為 test 的文件夾。 在 windows 中打開命令(“cmd.exe”)並輸入您創建的文件夾。 例如“ cd c:\test ”。 創建一個 cgi-bin 文件夾。 ex " mkdir cgi-bin " 運行 python 嵌入式服務器。 " python3 -m http.server --cgi " 把你的代碼放在 cgi-bin 文件夾中。 從瀏覽器訪問http://127.0.0.1:8000/cgi-bin/index.py
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.