如何在 CGIAr 中重定向到 Python 中的另一个页面

发布于 2024-08-16 00:05:02 字数 228 浏览 2 评论 0原文

如果我想使用以下核心库将用户从 cgi 脚本重定向到 HTML 页面:

import cgi

请有人为我指出正确的方向。而已。只需从 cgi 脚本重定向到 html 页面即可。你会怎么做这个Python。如果您必须物理地写出 HTTP 响应标头才能实现此目的,那么我将不胜感激有关如何执行此操作的任何信息。 蒂亚·

安德鲁

If I want to redirect the user from a cgi script to a HTML page using core libraries from the following:

import cgi

Please could someone point me in the right direction. Nothing more. Simply redirect from cgi script to html page. How ever you would do this Python. If you have to physically write out the HTTP Response Headers to achieve this, then I would appreciate any info on how to do this.
TIA

Andrew

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妄司 2024-08-23 00:05:02

除了 Location 之外,您还需要输出一个标头(“Status”),例如:

print "Status: 301 Moved",
print "Location:/wherever.com/"

You need to output one more header ("Status") in addition to the Location one, e.g.:

print "Status: 301 Moved",
print "Location:/wherever.com/"
眼睛会笑 2024-08-23 00:05:02

使用位置标头进行重定向

print "Location:URL\r\n"  # URL is the location where you want to redirct to

要记住的一点是位置标头应写在任何其他打印语句之前。如果在其之前编写其他打印语句,则位置标头将像平常一样打印在屏幕上文本。

To redirect use Location header

print "Location:URL\r\n"  # URL is the location where you want to redirct to

One point to remember is that location header should be written before any other print statements.If other print statements are written before it then the loaction header will be printed in the screen just as normal text.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文