defnull / multipart

A fast multipart/form-data parser for python
MIT License
126 stars 33 forks source link

Problems starting #39

Closed jabiertxof closed 2 years ago

jabiertxof commented 2 years ago

Hi trying to know how get post data as Python3 documentation point to this repo and no one guide to get working :( https://peps.python.org/pep-0594/#cgi

Finaly i found I need parse_form_data(environ)

But using it I get a endles loop in this line: `data = stream.read(mem_limit).decode(charset)

this is a min of my code that freeze wiuth no putput on post:

import os, sys, multipart

def getData(environ):
    try:
        if environ.get("REQUEST_METHOD", "GET").upper() in ("POST", "PUT"):
            return multipart.parse_form_data(environ)
        return ""
    except Exception as e:
        print(str(e))

def application(environ, start_response):
    try:
        q = getData(environ)
        print(q)
    except Exception as e:
        print(str(e))

from wsgiref.simple_server import make_server
httpd = make_server('', 8001, application)
print("Serving dynamic on port 8001...")
httpd.serve_forever()

Any help is welcome. Thanks in advance

jabiertxof commented 2 years ago

Python 3.10.5 data passed CONTENT_TYPE: application/x-www-form-urlencoded CONTENT_LENGTH: 50 wsgi.input: b'alias=javier%40foo.es&clave=1111111'

jabiertxof commented 2 years ago

Forget me im trying to pass a non multipart form data