I'm trying to write a webhook/callback python script to handle events raised by an email service provider (mailgun).
MailGun provides a 'test' button to test my handler. When they call my handler with an attachment, I encounter problems.
My first attempt was to use:
form = cgi.FieldStorage()
When I do this, cgi.FieldStorage() is the last call made by my script - and no errors are raised (it seems to hang).
I then attempted to use:
for line in sys.stdin:
Doing this helps - I get all of my data, but the loop never exits... it doesn't seem to be an infinite loop per say (it doesn't seem to be looping - I suspect it is trying to read that next line). My code after the loop never runs.
Question: What is causing cgi.FieldStorage() to seem to hang, and iterating sys.stdin to seem to hang?
I'm new to python - my debugging skills are weak :(
Some more info:
I'm using windows 2008, iis 7.5 (?), python 3.3 cgi (C:\Python33\python.exe -u %s %s).
I'm using iis's failed request logging (set up to log status 200)
Content-Type: multipart/form-data
Content-Length: 4225
This is some info about the attachment:
Content-Disposition: form-data; name="attachment-1"; filename="message.mime"
Content-Type: application/octet-stream
Content-Length: 1285
When mailgun doesn't send an attachment, I use cgi.FieldStorage() - and that works fine.