确定WSGI-Python中从HTML按下了哪个按钮(没有任何烧瓶和Django之类的框架?)>

问题描述 投票:0回答:1

我正在使用WSGI,python3和apache2在核心python中实现Web应用程序。现在我需要根据python WSGI文件中某个按钮的某些值或ID来检测按下了哪个按钮请提出我可以放置在WSGI文件中的代码。

Python代码:

def application(environ, start_response):
    if environ['REQUEST_METHOD'] == 'POST':
    post_env = environ.copy()
    post_env['QUERY_STRING'] = ''
    post = cgi.FieldStorage(fp=environ['wsgi.input'],
        environ=post_env,
        keep_blank_values=True
    )
    html =  page_header + content + page_footer
    start_response('200 OK', [('Content-Type', 'text/html')])
return [html.encode('utf-8')]

HTML代码:

<div> 
    <form method="post">
        <button id="button1">Button1</button>
        <input type="text"></input> Status 
        <button id="button2">Button2</button>
        <input type="text"></input> Status2
    </form>
</div> 

我希望代码能有生命

如果是“ button1”:“一些代码”如果是“ button2”:“一些代码”

我正在使用WSGI,python3和apache2在核心python中实现Web应用程序。现在,我需要根据python WSGI文件中某个按钮的某个值或ID来检测按下了哪个按钮,请...

html python-3.x wsgi
1个回答
0
投票

我已经使用AJAX将数据从HTML发送到WSGI

© www.soinside.com 2019 - 2024. All rights reserved.