Title: Allow uploading files with SimpleHTTPRequestHandler
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jacobsorme, jugmac00, lufte
Priority: normal Keywords:

Created on 2020-10-11 00:53 by lufte, last changed 2020-10-18 14:36 by jacobsorme.

File name Uploaded Description Edit
patch lufte, 2020-10-11 00:53 Suggested patch
Messages (5)
msg378418 - (view) Author: Javier Ayres (lufte) Date: 2020-10-11 00:53
Hello. I'm a big fan of the http.server module to quickly serve some files in a local network with `python3 -m http.server`. I regularly needed to get some files from other people too, but getting everyone to install/run python3 was not such a simple task. Eventually I wrote a subclass of SimpleHTTPRequestHandler that added a form with a file input and accepted POST requests, so people could also upload files to my computer. I think this would be a fine addition to SimpleHTTPRequestHandler, so I'm attaching a potential patch that implements this and adds a new cli parameter so this feature is only enabled explicitly.
msg378424 - (view) Author: Jürgen Gmach (jugmac00) * Date: 2020-10-11 07:51
There is PEP 594 (draft), which - when accepted - will remove cgi.FieldStorage

This comes from an idea to relief the burden of maintenance for the maintainers.

Some off-topic comments...

cgi.FieldStorage has quite some unresolved issues, partially open for many years, although there are also some pull requests, waiting for review.

While cgi.FieldStorage is certainly a niche thing, it is used by Zope, by Plone, by webob... 

The latter even has a 250 line compat module to accomodate for current bugs ( ).

If you, Javier, are also a fan of cgi.FieldStorage want to improve the situation with cgi.FieldStorage, maybe you could help reviewing the open issues and the open pull requests for cpython?
msg378498 - (view) Author: Javier Ayres (lufte) Date: 2020-10-12 14:14
I see. To be honest I didn't know FieldStorage at all, it was the best way I found of dealing with file data in requests using just the standard library. If you think this feature makes sense and it could be included, I could look into removing the FieldStorage dependency.
msg378550 - (view) Author: Jürgen Gmach (jugmac00) * Date: 2020-10-13 09:43
Disclaimer: I am not cpython maintainer - I just wanted to give a bit of context for using `cgi.FieldStorage`.

Personally, I'd rather not include this in the std, but create a small package for PyPI. But that's only me.

Wait until you get feedback from a cpython maintainer.
msg378866 - (view) Author: Jake (jacobsorme) Date: 2020-10-18 14:36
I would find this very useful.
Date User Action Args
2020-10-18 14:36:33jacobsormesetmessages: + msg378866
2020-10-18 09:46:30jacobsormesetnosy: + jacobsorme
2020-10-13 09:43:25jugmac00setmessages: + msg378550
2020-10-12 14:14:09luftesetmessages: + msg378498
2020-10-11 07:51:00jugmac00setnosy: + jugmac00
messages: + msg378424
2020-10-11 00:53:17luftecreate