[英]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.