【发布时间】:2018-12-05 16:34:35
【问题描述】:
我在 ubuntu 16.04 上使用 Xampp 7.2.6-0 和 Google Chrome 64.0.3282.186(官方构建)(64 位)。我正在尝试通过我的浏览器运行 python 脚本。我已经在 /opt/lampp/etc 中编辑了 httpd.conf 文件并附加了以下几行。
#edit by Wade King
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
我的 python 脚本名为 docxReader.py,位于 /opt/lampp/htdocs/PyFiles/XampPython/docxReader.py
看起来像这样并且编译没有错误:
#!/usr/bin/env python3
import cgitb
cgitb.enable()
print("Content-Type: text/html")
print("")
print("If you can read this inside a Web-Browser window, you can successfully run Python through XAMPP!'")
当我在浏览器中输入 http://localhost/PyFiles/XampPython/docxReader.py 时,结果是 docxReader.py 文件的文本,如下所示:
#!/usr/bin/env python3
import cgitb
cgitb.enable()
print("Content-Type: text/html")
print("")
print("If you can read this inside a Web-Browser window, you can successfully run Python through XAMPP!'")
我希望页面显示我的 python 文件的输出,而不是文件本身的文本。这是怎么回事,如何配置 Xampp 以显示我的 python 文件的输出?
【问题讨论】:
标签: python google-chrome ubuntu xampp