Created
April 10, 2020 17:20
-
-
Save Sean-Bradley/d2854fa1db4bfff595ddf5b8a7db644e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Copyright 2020 Sean Bradley https://sbcode.net/grafana/ MIT License | |
from flask import Flask, request | |
import boto3 | |
APP = Flask(__name__) | |
CLIENT = boto3.client( | |
"sns", | |
aws_access_key_id="your_access_key_id", | |
aws_secret_access_key="you_secret_access_key", | |
region_name="us-east-1" | |
) | |
@APP.route('/sendsms', methods=['POST']) | |
def sendsms(): | |
number = "+" + request.args.get('number') | |
print(number) | |
message = request.json["message"] | |
print(message) | |
response = CLIENT.publish( | |
PhoneNumber=number, | |
Message=message, | |
MessageAttributes={ | |
'AWS.SNS.SMS.SenderID': | |
{ | |
'DataType': 'String', | |
'StringValue': 'Grafana' | |
} | |
} | |
) | |
return response | |
APP.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment