That document is telling, that the function ‘urllib.parse.parse_qsl’ can be used for the requset method ‘GET’ and the function ‘email.message’ for ‘POST’. Because I’m not expert in Python. My current function contains as follows:
wrktbl = cgi.FieldStorage()
for wrkkey in wrktbl:
if isinstance(wrktbl[wrkkey], list):
wrkvlx = wrktbl[wrkkey][0].value
else:
wrkvlx = wrktbl[wrkkey].value
tblrqs[wrkkey] = wrkvlx
I wonder, whether anybody can convert that code for me. For instance:
import os
import urllib.parse.parse_qsl
import email.message
if os.environ('REQUEST_MODE') == 'GET':
.......
# How to get input and to convert to the variable table 'tblrqs'
.......
else if os.environ('REQUEST_MODE') == 'POST':
.......
# How to get input and to convert to the variable table 'tblrqs'
.......
As for the GET request parameters, I am able to extract them from the os.environ(‘QUERY_STRING’).
As for the POST request parameters, unfortunately I don’t see in the document ‘multipart’, how to extract the POST request parameters from wheret. Can I get any help from you for it? If yes, rather give me a clear example.