简体   繁体   English

将 html 表单值发布到没有 CGI 的 python 脚本

[英]Posting html form values to python script without CGI

I intend to write a Python script which receives some form data.我打算编写一个接收一些表单数据的 Python 脚本。 I think an HTML form is simple and good enough for my needs.我认为 HTML 表单简单且足以满足我的需求。 However, I have not found a way to feed the HTML form values to the Python script.但是,我还没有找到将 HTML 表单值提供给 Python 脚本的方法。 I do not want to use CGI as I want to avoid the use of a web sever.我不想使用 CGI,因为我想避免使用网络服务器。 The HTML form is intended to be a front end for the Python script. HTML 表单旨在成为 Python 脚本的前端。 Surely,there is a way to do this without CGI and a web server!当然,有一种方法可以在没有 CGI 和 Web 服务器的情况下做到这一点!

For creating the form, you can use the tkinter python module for graphic interface.要创建表单,您可以使用 tkinter python 模块进行图形界面。 It is fairly easy to create a page with different inputs that you can let your user fill in. The information will be provided as raw input rather than HTML form, but then you can use those entries directly in your following python script.使用不同的输入创建一个页面是相当容易的,您可以让您的用户填写。这些信息将作为原始输入而不是 HTML 表单提供,但是您可以直接在以下 python 脚本中使用这些条目。 https://docs.python.org/3/library/tkinter.html https://docs.python.org/3/library/tkinter.html

If you do want to go through an HTML form, you can then use the python module html.parser (ref. https://docs.python.org/3/library/html.parser.html )如果您确实想通过 HTML 表单,则可以使用 python 模块 html.parser (ref. https://docs.python.org/3/library/html.parser.html )

From the documentation, I think you can easily find your way through parsing your input files.从文档中,我认为您可以通过解析输入文件轻松找到自己的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM