运行CGI应用程序而无需从HTML重定向 [英] Run CGI application without redirecting from HTML
问题描述
我有一个从cgi应用程序填充的html页面。现在,当我通过表单
< form action = / cgi-bin / Lib .exe method = POST name = checks ID = Form2>
这使我从
http://localhost/index.html
到
http://localhost/cgi-bin/Lib.exe
,其中CGI输出我在其中放置的一些调试行。然后,我必须手动返回索引以查看它是否已更新。
当html表单向cgi应用程序发送请求时,CGi应用程序对数据库进行更新并重新编写索引html。我如何留在索引页面上并查看它的更新? (我正在运行重量轻的GoAhead Web服务器,C中的CGI和html,JS)
谢谢。
您可以从CGI脚本发送302状态代码,该代码会将用户的浏览器重定向到 /index.html
。 / p>
基本上,使CGI脚本吐出来:
HTTP / 1.1 302找到
位置:/index.html
I have an html page populated from a cgi app. Right now when I make a change on my html page through a form
<form action="/cgi-bin/Lib.exe" method=POST name="checks" ID="Form2">
It takes me from
http://localhost/index.html
to
http://localhost/cgi-bin/Lib.exe
where the CGI outputs some debug lines I put in there. I then have to manually go back to the index to see it updated.
When the html form sends a request to the cgi application, the CGi application makes the update to the database and re-writes the index html. How do I stay on the index page and see it updated? (I am running the light weight GoAhead web server, CGI in C, and html,JS)
Thanks.
You can send a 302 status code from the CGI script, which will redirect the user's browser to /index.html
.
Basically, make the CGI script spit this out:
HTTP/1.1 302 Found
Location: /index.html
这篇关于运行CGI应用程序而无需从HTML重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!