def messages(): # Handler for HTTP POST to http://symptomatic.me/messages api_key = os.environ.get('MAILGUN_APIKEY') token = request.form.get('token') signature = request.form.get('signature') sender = request.form.get('sender') recipient = request.form.get('recipient') body_plain = request.form.get('body-plain', '') timestamp = request.form.get('timestamp') date = datetime.fromtimestamp(int(timestamp)) e = Email.validate(date=date, sender=sender, body_plain=body_plain, symptoms=body_plain.splitlines()) mongo.save_email(e) return "OK" if _verify(api_key=api_key, token=token, timestamp=timestamp, signature=signature): date = datetime.fromtimestamp(int(timestamp)) e = Email.validate(date=date, sender=sender, body_plain=body_plain, symptoms=body_plain.splitlines()) mongo.save_email(e) return "OK" return "Nope", 404