Skip to content

Instantly share code, notes, and snippets.

@mseeks
Created February 8, 2024 02:27
Show Gist options
  • Save mseeks/4078d11e5d0111b12ef080e4fd2ee85f to your computer and use it in GitHub Desktop.
Save mseeks/4078d11e5d0111b12ef080e4fd2ee85f to your computer and use it in GitHub Desktop.
Python Flask app code snippet for handling MMS recorded via Twilio webhook, extracting the Media URL.
from flask import Flask, request
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def webhook():
# Assuming the incoming request is a form with 'MediaUrl0' for the first media item
media_url = request.form.get('MediaUrl0')
print(f'Media URL: {media_url}')
# Process the media as needed
# For an audio file, you might download it or pass it to another function for processing
return 'OK', 200
if __name__ == '__main__':
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment