【问题标题】:When try to execute a cgi script, get the error: "[WinError 193] %1 is not a valid Win32 application"尝试执行 cgi 脚本时,出现错误:“[WinError 193] %1 is not a valid Win32 application”
【发布时间】:2014-02-25 19:13:05
【问题描述】:

当我尝试执行 cgi 脚本(通过 localhost)时,我收到以下错误

OSError: [WinError 193] %1 is not a valid Win32 application

任何想法为什么??

完全迷路了……

.


附加信息:

localhost是由以下生成的

python -m http.server --cgi 8000

cgi 脚本由 ajax 'get' 请求调用(简化)

ajax({
   type: "GET", 
   url: "cgi-bin/myScript.cgi",
   onSuccess: function(html){
       //do stuff
   }
});

我已经测试过是否是 cgi 脚本的内容导致了这种情况,我确信这不是问题所在。例如,如果我尝试以上述方式执行一个空的“myScript.cgi”,我仍然会收到错误。

此外,cgi 脚本(用 python 编写)在通过命令行运行时可以正常工作。

【问题讨论】:

  • "user" => "bradley" 不是有效的 Python。
  • 哎呀,让我编辑那个...复制和粘贴问题

标签: python ajax cgi localhost


【解决方案1】:

原来是服务器配置错误....

我偶然发现了这个教程,

http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/dynamic.html

它引用了一个可用的 localCGIServer.py 脚本,

http://anh.cs.luc.edu/python/hands-on/examples/www/localCGIServer.py

服务器脚本完成工作

*

对于 Python 3 更改此行

cgiServer = BaseHTTPServer.HTTPServer(server_addr, CGIExtHTTPRequestHandler)

到

cgiServer = http.server.HTTPServer(server_addr, CGIExtHTTPRequestHandler)

【讨论】:

    猜你喜欢
    • 2019-02-24
    • 1970-01-01
    • 2022-06-17
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    相关资源
    最近更新 更多