https://github.com/superkabuki/nstuff
Python3 CGI GET / POST data (Replacement for cgi minifieldstorage)
https://github.com/superkabuki/nstuff
cgi fastcgi get minifieldstorage post python3
Last synced: 6 months ago
JSON representation
Python3 CGI GET / POST data (Replacement for cgi minifieldstorage)
- Host: GitHub
- URL: https://github.com/superkabuki/nstuff
- Owner: superkabuki
- License: bsd-3-clause
- Created: 2025-05-10T09:26:23.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-05-14T01:06:16.000Z (9 months ago)
- Last Synced: 2025-07-08T15:16:23.419Z (7 months ago)
- Topics: cgi, fastcgi, get, minifieldstorage, post, python3
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[Install](#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
```py3
#!/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
```js
a@fu:~$ curl https://iodisco.com/cb/nstuff.cgi?you=me
{"you": "me"}
```
* POST
```js
a@fu:~$ curl -d "say"="Hey Koolaid" https://iodisco.com/cb/nstuff.cgi
{"say": "Hey Koolaid"}
```
* Both in a POST
```js
a@fu:~$ curl -d "say"="Hey Koolaid" https://iodisco.com/cb/nstuff.cgi?adrian=iscool
{"adrian": "iscool", "say": "Hey Koolaid"}
```
# INSTALL
* Python3
```py3
python3 -mpip install nstuff
```
* __pypy3__
```py3
pypy3 -mpip install nstuff
```
* depending on the situation, you may need to add
```py3
--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.
