How to handle class instance that send through HTTP request?

Stack Overflow Asked by Senan Zedan on January 12, 2021

I have the class:

class ApplicationServer(BaseHTTPRequestHandler):
    def do_POST(self):
            content_type, post_dict = parse_header(self.headers['content-type'])
            if content_type == 'multipart/form-data':
                post_data = parse_multipart(self.rfile, post_dict)
            elif content_type == 'application/json':
                length = int(self.headers['content-length'])
                post_data = parse_qs(, keep_blank_values=1)
                post_data = {}

            new_data = {key.decode(): val[0].decode() for key, val in post_data.items()}

I’m sending through HTTP request class instance, But in the do_POST method it’s receiving as bytes and doing decode() convert it to string, my question is there any way to convert back to class instance?

The way that doing request:

if __name__ == '__main__':
    for i in range(11):
        order = Order(100, "Buy")
        status ="http://localhost:8000", data={"order": order}, headers={'Content-Type': 'application/json'})

Add your own answers!

Related Questions

Copy each cell in a range to multi-cell range

2  Asked on November 29, 2021 by preston-richardson


How to make dynamic custom textarea with jquery?

3  Asked on November 29, 2021 by david-noya


private static field Java

3  Asked on November 29, 2021


unordered_map excess calls to hash function

4  Asked on November 29, 2021 by amir-kirsh


cant load static file in django

1  Asked on November 29, 2021


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir