Example: Return POST and GET data from a request as JSON
- nstuff.cgi
#!/usr/bin/env python3
"""
Example nstuff cgi script to show GET and POST data.
"""
import json
from nstuff import nstuff
if __name__ == '__main__':
formstuff = nstuff()
print("Content-type: text/Json\n")
print(json.dumps(formstuff))
- GET
a@fu:~$ curl https://iodisco.com/cb/nstuff.cgi?you=me
{"you": "me"}
- POST
a@fu:~$ curl -d "say"="Hey Koolaid" https://iodisco.com/cb/nstuff.cgi
{"say": "Hey Koolaid"}
- Both in a POST
a@fu:~$ curl -d "say"="Hey Koolaid" https://iodisco.com/cb/nstuff.cgi?adrian=iscool
{"adrian": "iscool", "say": "Hey Koolaid"}
- Python3
python3 -mpip install nstuff
- pypy3
pypy3 -mpip install nstuff
- depending on the situation, you may need to add
--break-system-packages