예제 #1
0
def send_email(msg):
    from routes import app
    with app.app_context():
        mail = Mail()
        mail.init_app(current_app)
        print("hallo world")
        mail.send(msg)
예제 #2
0
def client():
    app.config.from_pyfile('{}/app/config/test.py'.format(cfg.BASE_DIR))
    client = app.test_client()

    with app.app_context():
        db.create_all()

    yield client
    os.unlink(app.config['DATABASE'])
예제 #3
0
def test_client():
    # Flask provides a way to test your application by exposing the Werkzeug test Client
    # and handling the context locals for you.
    testing_client = app.test_client()

    # Establish an application context before running the tests.
    ctx = app.app_context()
    ctx.push()

    yield testing_client  # this is where the testing happens!

    ctx.pop()
예제 #4
0
def app(request):
    """Session-wide test `Flask` application."""

    app = app1.test_client()

    # Establish an application context before running the tests.
    ctx = app1.app_context()
    ctx.push()

    def teardown():
        ctx.pop()

    request.addfinalizer(teardown)
    return app
예제 #5
0
def init_db(url):
	
	if os.path.exists(DATABASE):
	    os.remove(DATABASE)
	with app.app_context():
			    conn = sqlite3.connect(DATABASE)
			    data_url = url
			    
			    data_table = pd.read_csv(data_url)

			    data_table.to_sql('data_table', conn, dtype={
			    'checked':'INTEGER',
			    'result_type':'VARCHAR(10)',
			    'id':'INTEGER PRIMARY KEY',
			    'citation_id':'INTEGER',
			    'site_id':'INTEGER',
			    'treatment_id':'INTEGER',
			    'sitename':'VARCHAR(256)',
			    'city':'VARCHAR(10)',
			    'lat':'INTEGER',
			    'lon':'INTEGER',
			    'scientificname':'VARCHAR(256)',
			    'commonname':'VARCHAR(256)',
			    'genus':'VARCHAR(256)',
			    'species_id':'INTEGER',
			    'cultivar_id':'INTEGER',
			    'author':'VARCHAR(256)',
			    'citation_year':'INTEGER',
			    'treatment':'VARCHAR(256)',
			    'date':'VARCHAR(256)',
			    'time':'VARCHAR(256)',
			    'raw_date':'VARCHAR(256)',
			    'month':'VARCHAR(5)',
			    'year':'INTEGER',
			    'dateloc':'REAL',
			    'trait':'VARCHAR(256)',
			    'trait_description':'VARCHAR(256)',
			    'mean':'REAL',
			    'units':'VARCHAR(256)',
			    'n':'INTEGER',
			    'statname':'VARCHAR(5)',
			    'stat':'REAL',
			    'notes':'VARCHAR(256)',
			    'access_level':'INTEGER',
			    'cultivar':'VARCHAR(256)',
			    'entity':'VARCHAR(5)',
			    'method_name':'VARCHAR(256)',
			})
예제 #6
0
def send_email(organisation, recipients):
    sender = config.ADMINS[0]
    subject = 'Results have been generated for ' + organisation
    text_body = \
    """
    Greetings from Zense,

    We have completed your task in regards to %s
    Please visit us back

    Regards,
    Team Stalker, Zense """ % str(organisation)
    msg = Message(subject, sender = sender, recipients = recipients)
    msg.body = text_body
    with app.app_context():
        mail.send(msg)
예제 #7
0
def send_email(organisation, recipients):
    sender = config.ADMINS[0]
    subject = 'Results have been generated for ' + organisation
    text_body = \
    """
    Greetings from Zense,

    We have completed your task in regards to %s
    Please visit us back

    Regards,
    Team Stalker, Zense """ % str(organisation)
    msg = Message(subject, sender=sender, recipients=recipients)
    msg.body = text_body
    with app.app_context():
        mail.send(msg)
예제 #8
0
import os

from models import db
from routes import app

project_dir = os.path.dirname(os.path.abspath(__file__))

app.config[
    "SQLALCHEMY_DATABASE_URI"] = 'postgresql://*****:*****@localhost:5432/route'
db.init_app(app)

with app.app_context():
    db.create_all()

if __name__ == "__main__":
    app.run(debug=True)
def create_app():
    """Construct the core application."""

    with app.app_context():
        app.run()
        return app