__init__.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:myapp 作者: Lumenified 项目源码 文件源码
def create_app(config_name):
    """
    Main app settings
    """

    app = Flask(__name__, instance_relative_config=True)
    app.config.from_object(app_config[config_name])
    app.config.from_pyfile('config.py')
    db.init_app(app)

    """
    LoginManager settings
    """
    login_manager.init_app(app)
    login_manager.login_message = "Lutfen uye olunuz."
    login_manager.login_view = "uye.giris"

    migrate = Migrate(app, db)
    Bootstrap(app)

    from app import models

    from .admin import admin as admin_blueprint
    app.register_blueprint(admin_blueprint, url_prefix='/admin')

    from .Uye import uye as uye_blueprint
    app.register_blueprint(uye_blueprint)

    from .home import home as home_blueprint
    app.register_blueprint(home_blueprint)

    @app.errorhandler(403)
    def forbidden(error):
        return render_template('errors/Yasak.html', title='Yasak'), 403

    @app.errorhandler(404)
    def page_not_found(error):
        return render_template('errors/404.html', title='Sayfa Bulunamadi'), 404

    @app.errorhandler(500)
    def internal_server_error(error):
        return render_template('errors/500.html', title='Server Hatasi'), 500


    return app
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号