0
我的目标是我的SSI(shtml)将解析POST数据参数并返回一个长加密字符串,它将基于这些参数。 我使用IIS作为服务器。服务器端在IIS服务器上包含(ssi),读POST请求数据失败
我的约束:
- 我无法改变的URL - /document.shtml
- 的SHTML需要只返回基地64字符串结果。
我的尝试:
- 在SHTML使用 “EXEC CGI”,这样一来:
document.shtml:
<!--#exec cgi="/pythonApp/test.py?sdfsdf=sdfsdf" -->
test.py(简化版,没有加密背后的逻辑):
import cgitb
cgitb.enable()
import base64,urllib,json,os,sys
import cgi
print "Content-Type: text/plain;charset=utf-8"
print
cl, _ = cgi.parse_header(os.environ['CONTENT_LENGTH'])
if (int(cl)>0):
\t data = sys.stdin.read(int(cl))
\t input_j = json.loads(data)
\t print "AB : ",input_j["AB"]
else:
\t print "Failed to read POST request"
这里的问题是,如果我发送POST请求.../test.py,然后将其作品, 但如果我发送请求到document.shtml,内容长度仍然是积极的,如环境变量所述,但stdin会得到一个错误。
- 我的其它的想法是从SHTML本身读出的POST数据,以某种方式和其传递到CGI,这种方式:
<!--#exec cgi="/pythonApp/test.py?sdfsdf=sdfsdf" -->
问题是,我看了网,并没有找到一种方法来从shtml做到这一点。
有什么建议吗?我错过了一些简单的东西?