From django application to mod_wsgi wsgi application

15 views
Skip to first unread message

Luca

unread,
Feb 21, 2022, 2:18:56 PMFeb 21
to mod...@googlegroups.com
Good morning to all,

I have a django application that calls my python3 wsgi application. I will show you the code that simulates the behaviour. The 's' variable is what the Django application is sending to the WSGI application.


s = b'--a14c2bff457276f4b7efca76188ae034\\r\\nContent-Disposition: form-data; name="wkt"\\r\\n\\r\\nPOLYGON((662856.5265945033 5105763.789928524,665349.894261506 5105553.082801735,665174.3049891819 5104359.075749931,663594.0015382647 5104499.54716779,662856.5265945033 5105763.789928524))\\r\\n--a14c2bff457276f4b7efca76188ae034\\r\\nContent-Disposition: form-data; name="id"\\r\\n\\r\\n94\\r\\n--a14c2bff457276f4b7efca76188ae034\\r\\nContent-Disposition: form-data; name="proxy_csv"\\r\\n\\r\\n/it/admin/ws_trento/proxy/94/csv/\\r\\n--a14c2bff457276f4b7efca76188ae034\\r\\nContent-Disposition: form-data; name="user"\\r\\n\\r\\nLuca Manganelli\\r\\n--a14c2bff457276f4b7efca76188ae034--\\r\\n'


from urllib.parse import parse_qs

variable_list = parse_qs(s))
print(variable_list)


the output is:

{b'--123456789\\r\\nContent-Disposition: form-data; name': [b'"wkt"\\r\\n\\r\\nPOLYGON(())\\r\\n--a14c2bff457276f4b7efca76188ae034\\r\\nContent-Disposition: form-data; name="id"\\r\\n\\r\\n94\\r\\n--a14c2bff457276f4b7efca76188ae034\\r\\nContent-Disposition: form-data; name="proxy_csv"\\r\\n\\r\\n/test/94/csv/\\r\\n--a14c2bff457276f4b7efca76188ae034\\r\\nContent-Disposition: form-data; name="user"\\r\\n\\r\\ntestuser\\r\\n--a14c2bff457276f4b7efca76188ae034--\\r\\n']}


I see multiple Content-Disposition here that parse_qs is not able to interpret and thus I do not have a dictionary object. Can you point me to a solution to this problem?







Graham Dumpleton

unread,
Feb 21, 2022, 2:30:47 PMFeb 21
to mod...@googlegroups.com
For general questions which aren't specifically about mod_wsgi, you are better off asking on StackOverflow. Also, these sorts of issues are usually handled by a Python web framework, so if you aren't using one and are trying to do things using raw WSGI, I would suggest you use something like Flask instead. Otherwise you are going to have to drop down and use the cgi module (https://docs.python.org/3/library/cgi.html) to pull the requests apart yourself.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/CADyNUXBNxF7ZigTDXiTLphv_%2BfwQ-%2BUnjt3nkBJkN4Dihsw2EQ%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages