Example #1
0
def send_alert(body):
    client = Client(API().account_sid, API().auth_token)
    try:
        message = client.messages.create(from_=API().from_,
                                         body=body,
                                         to=API().to)

        return message.sid
    except:
        return False
Example #2
0
def get_location(latlng):
    geolocation_api = 'https://maps.googleapis.com/maps/api/geocode/json?latlng={}&key={}'.format(
        latlng,
        API().API_KEY)
    response = requests.get(geolocation_api)
    if response.json().get('results'):
        return {
            'Address':
            response.json().get('results')[0].get('formatted_address'),
            'Location':
            response.json().get('results')[0]['geometry']['location'],
            'Location_type':
            response.json().get('results')[0].get('location_type')
        }
    return {}
Example #3
0
# twilio for sending msg alert
from twilio.rest import Client
# ibm cloudant
from cloudant import Cloudant
from cloudant.adapters import Replay429Adapter

# algolia search api
from algoliasearch import algoliasearch

#Importing the flood risk data
sheetname = "NOAA"
noaa = pd.read_excel("./Datasets/DataVizFloodsFV3_22_2017.xlsx",
                     sheet_name=sheetname)

# algolia app connection
client = algoliasearch.Client(API().app_id, API().admin_api_key)
index = client.init_index('ema')

# Flask app connection
app = Flask(__name__)
app.secret_key = 'ResQU'
app.config['SESSION_TYPE'] = 'filesystem'

# cloudant Connection
client = None
db_name = 'resqu'
db = None

if 'VCAP_SERVICES' in os.environ:
    vcap = json.loads(os.getenv('VCAP_SERVICES'))
    if 'cloudantNoSQLDB' in vcap: