Python CGI - GET 表单,在浏览器中输入地址给出正确的页面
我正在尝试使用 python 和 CGI 制作一个网站。这个网站非常基础,它只有登录、注销和使用 sqlite 显示数据库中的数据。
我想知道如何使用不带提交按钮的 GET 表单创建指向显示从数据库返回的消息的页面的超链接?超链接类似于:
www.test.com/cgi-bin/test.py?message=id
其中 id 等于从数据库的列表(具有 id 和消息)返回的项目。因此,当我在浏览器中输入 message=23 时,它将单独在页面上显示该消息,或者当我使用查询字符串 message=43 创建超链接时,它将显示 ID 为 43 的消息。
我看过本教程(简单 URL 示例:获取方法部分): http://www.tutorialspoint.com/python/python_cgi_programming.htm
但我不知道如何摆脱提交按钮,其中的值来自数据库并附加到网址。 (test.py?foo=bar)
希望我已经清楚地解释了一切。
I'm trying to make a website using python with CGI. This website is very basic, all it has is login, logout and display data from a database using sqlite.
I was wondering how would I create a hyperlink to a page displaying a message returned from the database using a GET form with no submit button? The hyperlink would be something like:
www.test.com/cgi-bin/test.py?message=id
Where the id is equal to an item returned from a list (which has the id and message) from a database. So when I type into the browser say, message=23, it will display that message on a page alone or when I create a hyperlink with the query string message=43, it will display the message with ID 43.
I've looked at this tutorial (Simple URL example: get method part): http://www.tutorialspoint.com/python/python_cgi_programming.htm
But I don't know how I would get rid of the submit button with the values being from the database and appended to the URL. (test.py?foo=bar)
Hopefully I have explained everything clearly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
网址就是网址。无论您是通过输入、单击链接还是提交表单(使用 method=GET)来生成它都没有关系。
根据对问题实际上是的理解进行更新:
A URL is a URL. It doesn't matter if you generate it by typing it in, clicking a link, or submitting a form (with method=GET).
Update based on the understanding that the question is actually: