Example #1
0
    def create_app():

        global db, bootstrap, mail, login_manager, moment, pagedown
        app = Flask(__name__)

        from main import main as main_blueprint
        from auth import auth as auth_blueprint
        from admin import admin as admin_blueprint

        app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://flask:gf37888676@172.17.0.25/flask"
        app.config["SQLAlCHEMY_COMMIT_ON_TEARDOWN"] = True
        app.config["FLASK_ADMIN"] = "iamawar3player@163.com"
        app.config["FLASK_MAIL_SUBJECT_PREFIX"] = "[Flasky]"
        app.config["FLASK_MAIL_SENDER"] = "Flasky Admin <iamawar3player@163.com>"
        app.config["MAIL_SERVER"] = "smtp.163.com"
        app.config["MAIL_PORT"] = 25
        app.config["MAIL_USE_TLS"] = False
        app.config["MAIL_USERNAME"] = "iamawar3player@163.com"
        app.config["MAIL_PASSWORD"] = "fan86797121"
        app.config["DEBUG"] = True
        app.config["FLASKY_POSTS_PER_PAGE"] = 10
        app.config["SECRET_KEY"] = "gf37888676"
        app.register_blueprint(main_blueprint)
        app.register_blueprint(auth_blueprint, url_prefix="/auth")
        app.register_blueprint(admin_blueprint, url_prefix="/admin")

        db = db.init_app(app)
        mail = mail.init_app(app)
        bootstrap = bootstrap.init_app(app)
        login_manager = login_manager.init_app(app)
        moment = moment.init_app(app)
        pagedown = pagedown.init_app(app)

        return app
Example #2
0
    bootstrap = Bootstrap()

    app = Flask(__name__)
    app.config["SECRET_KEY"] = "hard to guess string"
    app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://root:mopon@172.16.34.7:3306/test"
    app.config["SQLALCHEMY_COMMIT_ON_TEARDOWN"] = True

    app.config["MAIL_SERVER"] = "smtp.qiye.163.com"
    app.config["MAIL_PORT"] = 25
    app.config["MAIL_USE_TLS"] = False
    app.config["MAIL_USERNAME"] = "chenxiaolu.sz@mopon.cn"
    app.config["MAIL_PASSWORD"] = "cxl@taijiu2015"
    app.config["FLASKY_MAIL_SUBJECT_PREFIX"] = "[Flasky]"
    app.config["FLASKY_MAIL_SENDER"] = "Flasky Admin <chenxiaolu.sz@mopon.cn>"
    app.config["FLASKY_ADMIN"] = "chenxiaolu.sz@mopon.cn"
    app.config["FLASKY_POSTS_PER_PAGE"] = 2
    app.config["FLASKY_FOLLOWERS_PER_PAGE"] = 2
    app.config["FLASKY_COMMENTS_PER_PAGE"] = 2

    bootstrap.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    mail.init_app(app)
    pagedown.init_app(app)

    from model import User, AnonymousUser

    @login_manager.user_loader
    def load_user(user_id):
        return User.query.get(int(user_id))