【问题标题】:SimpleHTTPServer which will allow an ajax request to execute a PY file?SimpleHTTPServer 将允许 ajax 请求执行 PY 文件?
【发布时间】:2017-08-28 13:12:32
【问题描述】:

我打算为我正在处理的 Python 脚本/模块制作一个简单的 Web 界面。我想提交可以执行 2 个选项中的 1 个的表单。修改一个配置json文件并运行python脚本,或者提交一个表单到python脚本并执行。

简单地说,我知道在使用其他一些应用程序(例如 Apache)时,您需要对其进行配置,使其接受 .py 文件作为可执行文件。与 SimpleHTTPServer 的情况相同吗?如果有,怎么做?

我在看:https://docs.python.org/2/library/simplehttpserver.html

我还在https://docs.python.org/2/library/basehttpserver.html#BaseHTTPServer.BaseHTTPRequestHandler 上查看 BaseHTTPServer,尽管在配置过程中没有任何反应

【问题讨论】:

    标签: python ajax python-2.7


    【解决方案1】:

    您可以启用SimpleHTTPServer的CGI(通用网关接口https://en.wikipedia.org/wiki/Common_Gateway_Interface),见下面的线程How to host python cgi script with `python -m SimpleHTTPServer 8000` or `python -m CGIHTTPServer 8000`?

    这类似于运行 Django (https://en.wikipedia.org/wiki/Django_(web_framework))。 Django 使用mod_wsgi 模块或 FastCGI 在兼容 WSGI 的网络服务器(Apache,...)上启用。

    【讨论】:

    • 哦。很高兴知道。我在看cgi,但不确定我想在多大程度上研究它。看起来它可能会成功。
    猜你喜欢
    • 2017-03-15
    • 2012-11-03
    • 1970-01-01
    • 2020-05-23
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    相关资源
    最近更新 更多