예제 #1
0
def sendMail(senderEmail, fileName):
    try:
        now = datetime.now()
        app.logger.info(
            str(now.strftime("%H:%M %Y-%m-%d")) + ' ' + __file__ + ' ' +
            inspect.stack()[0][3] + ' SenderEmail ' + senderEmail +
            ' FIleName ' + fileName)
        mail = Mail(app)
        token = User.get_file_download_token(fileName)
        msg = Message(
            subject="This is the data for which you had queried in the form.",
            sender=app.config['MAIL_USERNAME'],
            recipients=[senderEmail])
        with app.app_context():
            msg.body = f'''Please find your report at the link provided: { url_for('mailDownload', token=token, _external=True) }'''
            mail.send(msg)
        print("sent Successfully!!!!")
    except Exception as e:
        print(e)
예제 #2
0
from importlib import import_module
from modules import app

from . import security_api

with app.app_context():
    api_config = app.config.get("SECURITY_MODULE_ROUTES")
    if api_config:
        security_resources = import_module("modules.security.controllers")
        for api_name in api_config.keys():
            if api_config[api_name].get("url") is None:
                continue
            api_resource = getattr(security_resources, api_name)

            security_api.add_resource(
                api_resource,
                *(api_config[api_name]['url'],
                  api_config[api_name]['url'] + '/'))
    else:
        print("Error: Failed to load routes for the security module.")