def app():
    db_fd, db_path = tempfile.mkstemp()
    app = create_app({
        'DATABASE': db_path,
        'TESTING': True
    })

    yield app
Ejemplo n.º 2
0
def app():
    db_fd, db_path = tempfile.mkstemp()

    app = create_app({
        'TESTING': True,
        'DATABASE': db_path,
    })

    with app.app_context():
        init_db()
        get_db().executescript(_data_sql)

    yield app

    os.close(db_fd)
    os.unlink(db_path)
Ejemplo n.º 3
0
def test_config():
    assert not create_app().testing
    assert create_app({'TESTING': True}).testing
Ejemplo n.º 4
0
from baby import create_app

if __name__ == "__main__":
    app = create_app()
    app.run(host='0.0.0.0', port=5000, debug=True)
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
# @Author: durban.zhang
# @Date:   2019-11-13 16:30:07
# @Last Modified by:   durban.zhang
# @Last Modified time: 2019-11-28 10:41:14
from flask_mail import Message
from baby.extensions import mail
from baby import create_app
from baby.celery import create_celery
celery = create_celery(create_app())


@celery.task(name="tasks.add_together")
def add_together(a, b):
    return a + b


@celery.task(name="tasks.send_login_email")
def send_login_email(domain, user, email):

    subject = 'Hello, %s' % user
    html = '<p>Login <a target="_blank" href="%s">%s</a> Success</p>'
    msg = Message(
        sender='Walkerfree <*****@*****.**>',
        subject=subject,
        html=html % (domain, domain),
        recipients=[email]
    )

    mail.send(msg)