Skip to content

superkabuki/nstuff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install

nstuff

CGI GET / POST data

Replacement for the now defunct cgi MiniFieldStorage

Parse CGI GET and/or POST data into a dict

With a POST request you can parse POST data and the url query string.

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"}

INSTALL

  • Python3
python3 -mpip install nstuff 
  • pypy3
pypy3 -mpip install nstuff 
  • depending on the situation, you may need to add
--break-system-packages

The only method you need to call is nstuff() and it will return a dict of the request POST and GET vars . If you're just difficult, you can also call getstuff() or poststuff() directly and they will return the GET query string vars and POST data vars respectively.

image

About

Python3 CGI GET / POST data (Replacement for cgi minifieldstorage)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published