【问题标题】:How to pass the name of the html form / filename to python - CGI / HTML / Python如何将html表单/文件名的名称传递给python - CGI/HTML/Python
【发布时间】:2018-12-04 00:35:21
【问题描述】:

我在网上和 StackOverflow 上搜索了一堆,仍然没有找到答案。

我有两个 HTML 表单 something.html(针对用户)和 something_test.html(针对共同开发人员),它们都使用 POST 将表单中的输入传递给同一个 python 脚本。我的问题是我如何在 python 脚本中知道哪个 HTML 表单发送了输入?在我的例子中,如果它是“something_test.html”,那么显示的输出将会更加冗长。

表单名称是否存储在我可以在 python 脚本中解析的某个变量中。

提前感谢您的帮助。

【问题讨论】:

  • 您的表单应该发布到特定路线。

标签: python html cgi


【解决方案1】:

好的,假设您已经能够解析表单数据...

我会像这样在您的表单中添加一个隐藏的输入字段:

something.html

<input type="hidden" id="formName" name="name_of_form" value="something">

something_test.html

<input type="hidden" id="formName" name="name_of_form" value="something_test">

然后在你的python脚本中处理表单数据时,表单的名称将在“name_of_form”中可用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-29
    • 1970-01-01
    相关资源
    最近更新 更多