from flask import Flask, Response, request
import plivoxml
app=Flask(__name__)
@app.route('/record/voice_mail', methods=['GET','POST'])
def voice_mail():
response = plivoxml.Response()
response.addSpeak("Leave message. Press star key when done")
params = {
'maxLength' : "20",
'action' : "https://foo.com/get_recording/",
'finishOnKey' : "*"
}
response.addRecord(**params)
response.addSpeak("Recording not received.")
return Response(str(response), mimetype='text/xml')
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True)
# Sample Conference XML
# <Response>
# <Speak>
# Leave message.
# Press star key when done
# </Speak>
# <Record action="https://foo.com/get_recording/"
# finishOnKey="*" maxLength="20"/>
# <Speak>Recording not received.</Speak>
# </Response>