def recieve(request): logging.getLogger().setLevel(logging.DEBUG) l = LeakReport() params = request.POST l.leak = params['leakType'] l.severity = params['severity'] l.latitude = params['latitude'] l.longitude = params['longitude'] l.comments = params['comments'] l.sunet_id = params['sunetID'] t = tzinfo.FixedOffset(PSTOFFSET) l.report_time = datetime.now(tz=t) try: pic = request.FILES['file'].read() p = leakImage() logging.debug('pic: ' + str(pic)) m = images.resize(pic, 480) p.picture = db.Blob(m) s = p.put() l.pic = s.id() except: pass l.save() #return HttpResponse(content=l.report_time.strftime('%I:%M %B %d, %Y')) contact = EmergencyContact.objects.get() try: part1 = """ There has been a report of a """ part2 = str(l.severity) + " " + str(l.leak) part3 = """ at """ part4 = "http://maps.google.com/?q=" + str(l.latitude) + "," + str(l.longitude) + "&ll=" + str(l.latitude) + "," + str(l.longitude)+'&z=25' part5 = """ On """ part6 = str(l.report_time.strftime('%I:%M %B %d, %Y')) b = part1 + part2 + part3 + part4 + part5 message = mail.send_mail(sender = '*****@*****.**', to = contact.email, subject = 'New leak report', body = b ) except EmergencyContact.DoesNotExist: pass return HttpResponse(status=200)