我的django应用程序调用python cgi脚本:
def query(request):
if request.method == 'GET':
output = subprocess.check_output(['python', 'query.cgi']).decode('utf-8')
return HttpResponse(output, content_type="text/html")query.cgi将由一个表单调用。如何将类似"name=one&type=two“的参数传递给cgi。当我使用subprocess.check_output('python','query.cgi','name=one','type=two')时。它可以工作,但我如何将实时在线表单输入传递给cgi?非常感谢!
发布于 2016-09-20 06:51:20
它们在request的GET字典中传递
foo = request.GET['foo']
subprocess.check_output(['python', 'query.cgi', 'foo=' + foo])您还可以使用
request.GET.get('foo', 'def')在缺少键的情况下使用默认值。
https://stackoverflow.com/questions/39583157
复制相似问题