Skip to content

Instantly share code, notes, and snippets.

@cablehead
Created December 22, 2020 06:09
Show Gist options
  • Save cablehead/0e4ed3f5c669bdcd622448997764bc3f to your computer and use it in GitHub Desktop.
Save cablehead/0e4ed3f5c669bdcd622448997764bc3f to your computer and use it in GitHub Desktop.
Experimenting with processing http requests with jq + shell2http
#!/usr/local/bin/python3
import json
import sys
import os
fh = open("/tmp/out", "a")
env = dict(os.environ)
skip = ['HOME', 'TMPDIR', 'USER', 'LANG', 'PATH', 'PWD', 'SHLVL', 'SCRIPT_NAME' ]
for key in list(env.keys()):
if key in skip:
del env[key]
if key.startswith('_'):
del env[key]
json.dump({
'env': env,
'data': sys.stdin.read(),
}, fh)
fh.write('\n')
fh.close()
print("Content-Type: text/plain\n")
print("ack.")
shell2http -cgi -host localhost / cgi2json.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment