sparckles / Robyn

Robyn is a Super Fast Async Python Web Framework with a Rust runtime.
https://robyn.tech/
BSD 2-Clause "Simplified" License
3.9k stars 198 forks source link

Add support for form data built in! #756

Closed sansyrox closed 3 months ago

sansyrox commented 4 months ago

The current way to achieve this

import multipart as mp
from multipart import to_bytes

try:
    from io import BytesIO
except ImportError:
    from StringIO import StringIO as BytesIO

@app.get(‘/‘, methods=["GET","POST"])
def index():
                data = request.body
                p = mp.MultipartParser(BytesIO(to_bytes(data)),s)
                blob = p.parts()[0].value
                f = open("file.bin","wb")
                f.write(blob.encode("latin-1"))
                f.close()

Add support for form data built in!

isaacharrisholt commented 4 months ago

Thanks for this!