【问题标题】:Xampp not running pythonXampp没有运行python
【发布时间】:2018-12-05 16:34:35
【问题描述】:

我在 ubuntu 16.04 上使用 Xampp 7.2.6-0Google 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


    【解决方案1】:

    没关系,我想通了,我删除了

    AddHandler cgi-script .py
    ScriptInterpreterSource Registry-Strict
    

    我添加到 httpd.conf 末尾的行

    然后我在 httpd.conf 中找到了这一行:

    AddHandler cgi-script .cgi .pl
    

    并将 .py 附加到该行

    然后我只是运行chmod +x docxReader.py 使其可执行并在我的浏览器中打开文件,它似乎工作

    【讨论】:

      猜你喜欢
      • 2015-08-14
      • 2012-07-24
      • 1970-01-01
      • 2015-10-05
      • 2018-06-06
      • 2022-01-15
      • 2017-07-30
      • 2017-12-25
      • 2019-08-21
      相关资源
      最近更新 更多