Python CGI test:修订间差异
跳到导航
跳到搜索
(创建页面,内容为“=== Python CGI get post json === ==== test_cgi ==== #!/usr/bin/python3 # -*- coding: utf-8 -*- print("Content-type: text/html") print("") # import upy import os import time import ucgi import ustr import usys try: form = ucgi.uform()['CGI'] #d_form = form['CGI'] except Exception as e: print(e) sys.exit(1) print(form) #d_form = ustr.udict(form) for key, value in form.items(): if value[:8] == '%BASE64%':…”) |
小无编辑摘要 |
||
第53行: | 第53行: | ||
{'user': 'admin', 'passwd': '12345678', 'sql': '%BASE64%c2VsZWN0ICogZnJvbSBsX2V0bCB3aGVyZSBkYXRlX2lkID0gdG9fY2hhcihzeXNkYXRlLCAneXl5eW1tZGQnKQo='} | {'user': 'admin', 'passwd': '12345678', 'sql': '%BASE64%c2VsZWN0ICogZnJvbSBsX2V0bCB3aGVyZSBkYXRlX2lkID0gdG9fY2hhcihzeXNkYXRlLCAneXl5eW1tZGQnKQo='} | ||
{'user': 'admin', 'passwd': '12345678', 'sql': "select * from l_etl where date_id = to_char(sysdate, 'yyyymmdd')\n"} | {'user': 'admin', 'passwd': '12345678', 'sql': "select * from l_etl where date_id = to_char(sysdate, 'yyyymmdd')\n"} | ||
[[分类:Develop]] | |||
[[分类:Python]] |
2022年12月28日 (三) 11:23的版本
Python CGI get post json
test_cgi
#!/usr/bin/python3 # -*- coding: utf-8 -*- print("Content-type: text/html") print("") # import upy import os import time import ucgi import ustr import usys try: form = ucgi.uform()['CGI'] #d_form = form['CGI'] except Exception as e: print(e) sys.exit(1) print(form) #d_form = ustr.udict(form) for key, value in form.items(): if value[:8] == '%BASE64%': form[key] = usys.base64(value) print(form)
Example:
Get
curl "http://10.10.137.16/cgi-bin/test_cgi?user=admin&passwd=12345678" {'passwd': '12345678', 'user': 'admin'} {'passwd': '12345678', 'user': 'admin'}
Post
curl -d "user=admin&passwd=12345678" http://10.10.137.16/cgi-bin/test_cgi {'user': 'admin', 'passwd': '12345678'} {'user': 'admin', 'passwd': '12345678'}
Post Json
T1="{'user': 'admin', 'passwd': '12345678', 'sql':'%BASE64%c2VsZWN0ICogZnJvbSBsX2V0bCB3aGVyZSBkYXRlX2lkID0gdG9fY2hhcihzeXNkYXRlLCAneXl5eW1tZGQnKQo='}" URL="http://10.10.137.16/cgi-bin/test_cgi" curl -H "Content-Type:application/json" -X POST -d "$T1" $URL {'user': 'admin', 'passwd': '12345678', 'sql': '%BASE64%c2VsZWN0ICogZnJvbSBsX2V0bCB3aGVyZSBkYXRlX2lkID0gdG9fY2hhcihzeXNkYXRlLCAneXl5eW1tZGQnKQo='} {'user': 'admin', 'passwd': '12345678', 'sql': "select * from l_etl where date_id = to_char(sysdate, 'yyyymmdd')\n"}