Posting html form values to python script

前端 未结 2 728
不知归路
不知归路 2020-12-13 15:15

I have created html form with text box and button

enter ur search keyword

My requirement is to pass the text box value in to my test.py code, is there any

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 15:59

    in the form action form action="", put the location of your cgi script and the value of the textbox will be passed to the cgi script. eg.

    Search:

    in your test.py

    import cgi
    form = cgi.FieldStorage()
    searchterm =  form.getvalue('searchbox')
    

    thus you will get the key word entered in search text box in searchterm variable in python.

提交回复
热议问题