Here's an example html file and accompanying python CGI script which should get you going:
Using this html:
test
and this script:
#!/usr/bin/env python
import sys
import json
import cgi
fs = cgi.FieldStorage()
sys.stdout.write("Content-Type: application/json")
sys.stdout.write("\n")
sys.stdout.write("\n")
result = {}
result['success'] = True
result['message'] = "The command Completed Successfully"
result['keys'] = ",".join(fs.keys())
d = {}
for k in fs.keys():
d[k] = fs.getvalue(k)
result['data'] = d
sys.stdout.write(json.dumps(result,indent=1))
sys.stdout.write("\n")
sys.stdout.close()
After clicking the button you can see the cgi script returns:
{
"keys": "key2,key",
"message": "The command Completed Successfully",
"data": {
"key2": "value2",
"key": "value"
},
"success": true
}