Exemple #1
0
def init_extensions(app):
    # Init database
    from extensions import db
    db.init_app(app)

    # Init migration
    from extensions import migrate
    migrate.init_app(app, db)

    # Init bcrypt
    from extensions import bcrypt
    bcrypt.init_app(app)

    # Init Login manager
    from extensions import login_mgr
    login_mgr.login_view = 'auth.login'
    login_mgr.init_app(app)

    # Init mail
    from extensions import mail
    mail.init_app(app)

    # Init jwt
    from extensions import jwt
    jwt.init_app(app)
Exemple #2
0
def register_extensions(app):

    # ..config
    config.init_app(app)

    # ..bcrypt
    bcrypt.init_app(app)

    # ..db
    db.init_app(app)

    # ..csrf
    csrf_protect.init_app(app)

    # ...login_manager
    login_manager.init_app(app)
    login_manager.login_view = 'accounts.login'
    login_manager.login_message = None

    @login_manager.user_loader
    def load_user(user_id):
        from accounts.models import User
        return User.get_by_id(user_id)

    # ..migrate
    migrate.init_app(app, db)

    # ..webpack
    if not app.config['MIGRATION_MODE']:
        webpack.init_app(app)

    # ...
    return None
def extensions(app):

    bcrypt.init_app(app)
    login.init_app(app)
    db.init_app(app)
    mail.init_app(app)

    return None
Exemple #4
0
def register_extensions(app):
    from extensions import bcrypt, db, jwt

    app.config.from_envvar('ENV_FILE_LOCATION')

    bcrypt.init_app(app)
    db.init_app(app)
    jwt.init_app(app)
Exemple #5
0
def register_extensions(app):
    db.init_app(app)
    bcrypt.init_app(app)
    lm.init_app(app)
    lm.login_view = 'auth.login'
    toolbar.init_app(app)
    mail.init_app(app)
    migrate.init_app(app, db)
    return None
Exemple #6
0
def register_extensions(app):
	database.init_app(app)
	db_init(app.config.get("DROP_DB"))
	login_manager.init_app(app)
	login_manager.session_protection = "strong"
	login_manager.login_view = "main.login"
	bcrypt.init_app(app)

	return None
Exemple #7
0
def register_extensions(app):
    assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    return None
Exemple #8
0
def create_app(config=None):
    new_app = Flask(__name__,
                    template_folder='../react_app/build',
                    static_folder='../react_app/build/static')
    new_app.config.from_object(config)

    with new_app.app_context():
        jwt.init_app(new_app)
        bcrypt.init_app(new_app)
        cors.init_app(new_app)
        mysql.init_app(new_app)
        mail.init_app(new_app)

    from model import temp_blacklist

    @jwt.token_in_blacklist_loader
    def check_if_token_in_blacklist(decrypted_token):
        return decrypted_token['jti'] in temp_blacklist

    # Let react handle routing
    @new_app.route('/', defaults={'path': ''})
    @new_app.route('/<path:path>')
    def serve(path):
        if path and os.path.exists(safe_join(new_app.template_folder, path)):
            return send_from_directory(new_app.template_folder, path)
        else:
            return send_from_directory(new_app.template_folder, 'index.html')

    from resources.authentication import (UserRegistration, UserLogin,
                                          TokenRefresh, UnsetToken, AdminLogin,
                                          AdminRegister)
    from resources.user import GetUserInfo, UpdateUserInfo
    from resources.products import (TrackProduct, NewComments, GetComments,
                                    GetSpecificProduct)
    from resources.admin import Announcement

    api.add_resource(UserRegistration, '/register')
    api.add_resource(UserLogin, '/login')
    api.add_resource(TokenRefresh, '/refresh')
    api.add_resource(UnsetToken, '/revoke')
    api.add_resource(GetUserInfo, '/user')
    api.add_resource(UpdateUserInfo, '/user/<string:option>')
    api.add_resource(TrackProduct, '/product')
    api.add_resource(GetSpecificProduct,
                     '/product/<string:retailer>/<string:pid>')
    api.add_resource(NewComments, '/comment')
    api.add_resource(GetComments,
                     '/comment/<string:retailer>/<string:prod_id>')
    api.add_resource(AdminLogin, '/admin-login')
    api.add_resource(AdminRegister, '/admin-register')
    api.add_resource(Announcement, '/announcement')

    api_bp = Blueprint('api', __name__)
    api.init_app(api_bp)
    new_app.register_blueprint(api_bp, url_prefix='/api')
    return new_app
def register_extensions(app):
    """Register Flask extensions."""
    db.init_app(app)
    migrate.init_app(app, db)
    login_manager.init_app(app)
    bcrypt.init_app(app)
    if not scheduler.running:
        scheduler.init_app(app)
        scheduler.start()
    jwt.init_app(app)
Exemple #10
0
def configure_extensions(app):
    login_manager = LoginManager()
    login_manager.init_app(app)

    @login_manager.user_loader
    def load_user(id):
        return User.query.filter_by(id=id).first()

    db.init_app(app)
    bcrypt.init_app(app)
def register_extensions(app):
    """Register Flask extensions."""
    bcrypt.init_app(app)
    # cache.init_app(app)
    db.init_app(app)
    ma.init_app(app)
    migrate.init_app(app, db)
    jwt.init_app(app)
    # redis_store.init_app(app)
    logging.config.dictConfig(app.config["LOGGING"])
    return app
Exemple #12
0
def configure_extensions(app):
    # setup SQLAlchemy
    db.init_app(app)
    # db.drop_all(app=app)
    db.create_all(app=app)
    from dummy_data import create_test_data
    # create_test_data(app)

    mail.init_app(app)

    bcrypt.init_app(app)
Exemple #13
0
def register_extensions(app):
    """Register Flask extensions."""
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    csrf_protect.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    flask_static_digest.init_app(app)
    return None
Exemple #14
0
def extensions(app):
    """
    Register 0 or more extensions (mutates the app passed in).

    :param app: Flask application instance
    :return: None
    """

    migrate.init_app(app, db)
    cors.init_app(app)
    bcrypt.init_app(app)
    api.init_app(app)
Exemple #15
0
def create_app(object_name):
    """Create the app instance via `Factory Method`"""

    app = Flask(__name__)
    app.config.from_object(object_name)
    db.init_app(app)
    bcrypt.init_app(app)

    app.register_blueprint(blog.blog_blueprint)
    app.register_blueprint(main.main_blueprint)

    return app
Exemple #16
0
def configure_extensions(app):
    db.init_app(app)
    # login_manager.refresh_view = 'user.reauth'
    login_manager.init_app(app)

    @login_manager.user_loader
    def user_loader(user_email):
        return User.query.filter_by(email=user_email).first()

    login_manager.login_view = 'user.signin'
    login_manager.login_message_category = "info"
    mail.init_app(app)
    bcrypt.init_app(app)
def configure_extensions(app):

    configure_assets(app)
    bcrypt.init_app(app)
    babel.init_app(app)
    cache.init_app(app)
    celery = Celery(app)
    mail.init_app(app)
    mongodb.init_app(app)
    sqldb.init_app(app)

    if app.debug:
        debugtoolbar = DebugToolbarExtension(app)
Exemple #18
0
def config_app(app, config):
    app.logger.info('Setting up application...')

    app.logger.info('Loading config file: %s' % config)
    app.config.from_pyfile(config)

    app.logger.info('Setting up extensions...')
    db.init_app(app)
    # Init the Flask-Bcrypt via app object
    bcrypt.init_app(app)

    # Init the Flask-Login via app object
    login_manager.init_app(app)
    # Init the Flask-Prinicpal via app object
    principals.init_app(app)

    @identity_loaded.connect_via(app)
    def on_identity_loaded(sender, identity):
        """Change the role via add the Need object into Role.

           Need the access the app object.
        """

        # Set the identity user object
        identity.user = current_user

        # Add the UserNeed to the identity user object
        if hasattr(current_user, 'id'):
            identity.provides.add(UserNeed(current_user.id))

        # Add each role to the identity user object
        if hasattr(current_user, 'roles'):
            for role in current_user.roles:
                identity.provides.add(RoleNeed(role.name))
    # 自定义全局函数
    app.add_template_global(admin_permission, 'admin_permission')
    app.add_template_global(app.config.get('VERSION_NO'), 'version_no')

    # Init the Flask-Cache via app object
    cache.init_app(app)


    @app.after_request
    def after_request(response):
        try:
            db.session.commit()
        except Exception:
            db.session.rollback()
            abort(500)
        return response
Exemple #19
0
def configure_extensions(app):
    # flask-mongoengine
    db.init_app(app)
    app.session_interface = MongoEngineSessionInterface(db)
    # flask-mail
    mail.init_app(app)

    # flask-babel
    babel.init_app(app)

    # Bcrypt for hashing passwords
    bcrypt.init_app(app)

    # the Gravatar service
    gravatar.init_app(app)

    # Markdown
    md.init_app(app)

    # Caching
    cache.init_app(app)

    # Debug Toolbar
    if app.debug:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)

    @babel.localeselector
    def get_locale():
        """
        Get the current request locale.

        returns String

        """
        if not hasattr(g, 'lang'):
            g.lang = 'en'
        accept_languages = app.config.get('ACCEPT_LANGUAGES')
        return g.lang or request.accept_languages.best_match(accept_languages)

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects(id=user_id).first()

    login_manager.setup_app(app)
Exemple #20
0
def configure_extensions(app):
    # flask-mongoengine
    db.init_app(app)
    app.session_interface = MongoEngineSessionInterface(db)
    # flask-mail
    mail.init_app(app)

    # flask-babel
    babel.init_app(app)

    # Bcrypt for hashing passwords
    bcrypt.init_app(app)

    # the Gravatar service
    gravatar.init_app(app)

    # Markdown
    md.init_app(app)

    # Caching
    cache.init_app(app)

    # Debug Toolbar
    if app.debug:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)

    @babel.localeselector
    def get_locale():
        """
        Get the current request locale.

        returns String

        """
        if not hasattr(g, 'lang'):
            g.lang = 'en'
        accept_languages = app.config.get('ACCEPT_LANGUAGES')
        return g.lang or request.accept_languages.best_match(accept_languages)

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects(id=user_id).first()

    login_manager.setup_app(app)
Exemple #21
0
def create_app(object_name):
    """
    工厂模式的创建
    :param object_name: 不同的对象模式
    :return: 特定的app对象实例
    """
    app = Flask(__name__)
    app.config.from_object(object_name)
    # 数据库
    db.init_app(app)
    # Bcrypt加密库
    bcrypt.init_app(app)

    # 注册蓝本
    app.register_blueprint(blog.blog_blueprint)
    app.register_blueprint(main.main_blueprint)
    return app
Exemple #22
0
def create_app():
    app = Flask(__name__)
    app.config.from_object('config')
    db.init_app(app)
    bcrypt.init_app(app)
    migrate.init_app(app, db)
    csrf_protect.init_app(app)
    login_manager.init_app(app)
    app.register_blueprint(main)
    app.register_blueprint(auth)
    app.register_blueprint(sale)
    app.register_blueprint(people)
    app.register_blueprint(setting)
    app.register_blueprint(transaction)
    app.register_blueprint(inventory)
    app.register_blueprint(report)

    return app
Exemple #23
0
def create_app(object_name):
    app = Flask(__name__)
    app.config.from_object(object_name)

    db.init_app(app)
    mongo.init_app(app)
    bcrypt.init_app(app)
    celery.init_app(app)
    event.listen(Reminder, 'after_insert', on_reminder_save)

    @app.route('/')
    def index():
        return redirect(url_for('blog.home'))

    app.register_blueprint(blog_blueprint)
    app.register_blueprint(main_blueprint)

    return app
Exemple #24
0
def config_extensions(app):
    db.init_app(app)
    api.init_app(app)
    bcrypt.init_app(app)

    # 配置验证, HTTP BASE Authenticate
    @auth.verify_password
    def verify_password(username_or_token, password):
        # first tyr to authenticate by token
        user = User.virify_auth_token(username_or_token)
        if not user:
            # try to authenticate by token

            user = User.query.filter_by(username=username_or_token).first()
            # user = User.get_user_by_name(username_or_token)
            if not user or not user.verify_password(password):
                return False
        g.user = user
        return True
Exemple #25
0
def config_extensions(app):
    db.init_app(app)
    api.init_app(app)
    bcrypt.init_app(app)

    # 配置验证, HTTP BASE Authenticate
    @auth.verify_password
    def verify_password(username_or_token, password):
        # first tyr to authenticate by token
        user = User.virify_auth_token(username_or_token)
        if not user:
            # try to authenticate by token

            user = User.query.filter_by(username=username_or_token).first()
            # user = User.get_user_by_name(username_or_token)
            if not user or not user.verify_password(password):
                return False
        g.user = user
        return True
Exemple #26
0
def create_app(object_name):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. project.config.ProdConfig
    """

    app = Flask(__name__)
    app.config.from_object(object_name)

    db.init_app(app)
    mongo.init_app(app)

    bcrypt.init_app(app)
    oid.init_app(app)
    login_manager.init_app(app)
    principals.init_app(app)

    @identity_loaded.connect_via(app)
    def on_identity_loaded(sender, identity):
        # Set the identity user object
        identity.user = current_user

        # Add the UserNeed to the identity
        if hasattr(current_user, 'id'):
            identity.provides.add(UserNeed(current_user.id))

        # Add each role to the identity
        if hasattr(current_user, 'roles'):
            for role in current_user.roles:
                identity.provides.add(RoleNeed(role.name))

    app.register_blueprint(main_blueprint)
    app.register_blueprint(blog_blueprint)

    return app
Exemple #27
0
def __create_app(configs):
    static_folder = None
    for config in configs:
        if hasattr(config, 'STATIC_FOLDER'):
            static_folder = config.STATIC_FOLDER

    app = Flask(__name__,
                instance_relative_config=True,
                static_folder=static_folder)

    for config in configs:
        app.config.from_object(config)

    # Initializing extensions
    from extensions import bcrypt
    bcrypt.init_app(app)
    from extensions import db
    db.init_app(app)
    from extensions import mail
    mail.init_app(app)

    return app
Exemple #28
0
def create_app(object_name):
    app = Flask(__name__)
    app.config.from_object(object_name)

    CORS(app, resources={r"/api/*": {"origins": "*"}})
    db.init_app(app)
    bcrypt.init_app(app)
    login_manager.init_app(app)

    rest_api.add_resource(ProductApi,
                          '/api/1/product',
                          '/api/1/product/<int:product_id>',
                          endpoint='product')

    rest_api.add_resource(ProductSkuApi,
                          '/api/1/sku',
                          '/api/1/sku/<int:sku_id>',
                          endpoint='sku')

    rest_api.add_resource(CategoryApi,
                          '/api/1/category',
                          '/api/1/category/<int:category_id>',
                          endpoint='category')

    rest_api.add_resource(CreateUserApi,
                          '/api/1/auth/create',
                          endpoint='auth_create')

    rest_api.add_resource(
        AuthApi,
        '/api/1/auth',
        endpoint='auth',
    )

    rest_api.init_app(app)

    return app
Exemple #29
0
def create_app(object_name):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Arguments:
        object_name: the python path of the config object,
                     e.g. project.config.ProdConfig
    """

    app = Flask(__name__)
    app.config.from_object(object_name)

    db.init_app(app)
    bcrypt.init_app(app)
    oid.init_app(app)
    login_manager.init_app(app)
    principals.init_app(app)

    @identity_loaded.connect_via(app)
    def on_identity_loaded(sender, identity):
        # Set the identity user object
        identity.user = current_user

        # Add the UserNeed to the identity
        if hasattr(current_user, 'id'):
            identity.provides.add(UserNeed(current_user.id))

        # Add each role to the identity
        if hasattr(current_user, 'roles'):
            for role in current_user.roles:
                identity.provides.add(RoleNeed(role.name))

    app.register_blueprint(main_blueprint)
    app.register_blueprint(blog_blueprint)

    return app
Exemple #30
0
def create_app(config_filename):
    app = Flask(__name__, static_folder="../react_frontend/build/static", template_folder="../react_frontend/build")
    app.config.from_object(config_filename)
    app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = SQLALCHEMY_TRACK_MODIFICATIONS

    bcrypt.init_app(app)
    db.init_app(app)

    @login_manager.user_loader
    def load_user(user_id):
        print(user_id, "loaduser user_loder id")
        try:
            return db.session.query(User).filter_by(user_id=int(user_id)).first()
        except:
            return "gneka"

    login_manager.init_app(app)

    CORS(app, support_credentials=True)

    app.register_blueprint(api_bp, url_prefix='/api')



    @app.after_request
    def middleware_for_response(response):
        # Allowing the credentials in the response.
        response.headers.add('Access-Control-Allow-Origin', request.headers.get("origin"))
        response.headers.add("Access-Control-Allow-Credentials", "true")
        response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,PATCH,HEAD,DELETE,UPDATE,OPTIONS')
        response.headers.add('Access-Control-Allow-Headers', 'Authorization, X-PINGOTHER, X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept, withCredentials')

        return response

    return app
Exemple #31
0
def configure_extensions(app):
    # flask-mongoengine
    db.init_app(app)
    app.session_interface = MongoEngineSessionInterface(db)
    # flask-mail
    mail.init_app(app)

    # flask-babel
    babel.init_app(app)

    # Bcrypt for hashing passwords
    bcrypt.init_app(app)

    # the Gravatar service
    gravatar.init_app(app)

    # Markdown
    md.init_app(app)

    # Caching
    cache.init_app(app)

    # Debug Toolbar
    if app.debug and app.config['DEBUG_TB_PROFILER_ENABLED']:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)

    @babel.localeselector
    def get_locale():
        """
        Get the current request locale.

        returns String

        """
        if not hasattr(g, 'lang'):
            g.lang = app.config.get('BABEL_DEFAULT_LOCALE')
        accept_languages = app.config.get('ACCEPT_LANGUAGES')
        # Try to guess the language from the user accept
        # header the browser transmits. We support ar/fr/en,
        # The best match wins.

        g.lang = session.get('language', None) or \
            request.accept_languages.best_match(accept_languages) or \
            g.lang

        if g.lang == 'ar':
            g.lang_dir = 'rtl'
            g.layout_dir_class = 'right-to-left'
            g.language_name = u'العربية'
        else:
            g.lang_dir = 'ltr'
            g.layout_dir_class = 'left-to-right'
            g.language_name = 'English' if g.lang == 'en' else u'Français'

        return g.lang

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects(id=user_id).first()

    login_manager.setup_app(app)
Exemple #32
0
def create_app(config_name):
    """
    An flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/
    Arguments:
        config_name: the key value if the config.config dict,
                     e.g. 'dev', 'test', 'product', 'default'
    """

    app = Flask(__name__)
    app.config.from_object(config[config_name])
    # 首先调用配置对象的init_app
    config[config_name].init_app(app)

    # init SQLAlchemy
    db.init_app(app)
    # init Bcrypt
    bcrypt.init_app(app)
    # init LoginManager
    login_manager.init_app(app)
    # init Principal
    principal.init_app(app)

    @identity_loaded.connect_via(app)
    def on_identity_loaded(sender, identity):
        # Set the identity user object
        identity.user = current_user
        # Add the UserNeed to the identity
        if hasattr(current_user, 'id'):
            identity.provides.add(UserNeed(current_user.id))
        # Add each role to the identity
        if hasattr(current_user, 'roles'):
            for role in current_user.roles:
                identity.provides.add(RoleNeed(role.name))

    # init DebugToolbarExtension
    debug_toolbar.init_app(app)

    # init Cache
    cache.init_app(app)

    # init Flask-Assets
    assets_env.init_app(app)
    assets_env.register("main_css", main_css)
    assets_env.register("main_js", main_js)

    # init Flask-Admin
    admin.init_app(app)
    admin.add_view(CustomView(name='Custom'))

    models = [User, Role, Comment, Tag]
    for model in models:
        admin.add_view(CustomModelView(model, db.session, category='Models'))
    # 单独处理Post model,因为我们自定了CustomModelView的自类PostView
    admin.add_view(PostView(Post, db.session, category='Models'))

    admin.add_view(CustomFileAdmin(
        os.path.join(os.path.dirname(__file__), 'static'),
        '/static/',
        name='Static Files'
    ))

    # init Flask-Bootstrap
    bootstrap.init_app(app)

    # init Flask-Mail
    mail.init_app(app)

    # init Flask-Moment
    moment.init_app(app)

    ############################################################################

    # init RestApi
    rest_api.add_resource(PostApi, '/api/post', '/api/post/<int:post_id>',
                          endpoint='api')
    rest_api.add_resource(AuthApi, '/api/auth')
    rest_api.init_app(app)

    # register blueprint
    app.register_blueprint(blog_blueprint)
    app.register_blueprint(main_blueprint)
    app.register_blueprint(auth_blueprint)
    # register api blueprint
    app.register_blueprint(api_blueprint)

    return app
Exemple #33
0
def configure_extensions(app):
    # flask-mongoengine
    db.init_app(app)
    app.session_interface = MongoEngineSessionInterface(db)
    # flask-mail
    mail.init_app(app)

    # flask-babel
    babel.init_app(app)

    # Bcrypt for hashing passwords
    bcrypt.init_app(app)

    # the Gravatar service
    gravatar.init_app(app)

    # Markdown
    md.init_app(app)

    # Caching
    cache.init_app(app)

    # Debug Toolbar
    if app.debug and app.config['DEBUG_TB_PROFILER_ENABLED']:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)

    @babel.localeselector
    def get_locale():
        """
        Get the current request locale.

        returns String

        """
        if not hasattr(g, 'lang'):
            g.lang = app.config.get('BABEL_DEFAULT_LOCALE')
        accept_languages = app.config.get('ACCEPT_LANGUAGES')
        # Try to guess the language from the user accept
        # header the browser transmits. We support ar/fr/en,
        # The best match wins.

        g.lang = session.get('language', None) or \
            request.accept_languages.best_match(accept_languages) or \
            g.lang

        if g.lang == 'ar':
            g.lang_dir = 'rtl'
            g.layout_dir_class = 'right-to-left'
            g.language_name = u'العربية'
        else:
            g.lang_dir = 'ltr'
            g.layout_dir_class = 'left-to-right'
            g.language_name = 'English' if g.lang == 'en' else u'Français'

        return g.lang

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects(id=user_id).first()

    login_manager.setup_app(app)
from flask_graphql import GraphQLView
from extensions import bcrypt, auth, jwt
from schema import auth_required_schema, schema
from dotenv import load_dotenv
from flask_jwt_extended import (create_access_token, create_refresh_token,
                                get_jwt_identity, jwt_required)
import os
from models import User, session

load_dotenv()

app = Flask(__name__)
app.config['SECRET_KEY'] = os.getenv('secret')
app.config['JWT_SECRET_KEY'] = os.getenv('jwtsecret')

bcrypt.init_app(app)
auth.init_app(app)
jwt.init_app(app)


@app.route('/')
def index():
    return "Go to /graphql"


@app.route('/login', methods=['POST'])
def login():
    # fetch login credentials
    data = request.get_json(force=True)
    # find user
    user = session.query(User).filter_by(email=data['email']).first()
Exemple #35
0
def register_extensions(app):
    init_db(app)
    bcrypt.init_app(app)
    cors.init_app(app)
Exemple #36
0
def register_extensions(app):
    bcrypt.init_app(app)
    db.init_app(app)
    giphyApi.init_app(app)
    jwt.init_app(app)
Exemple #37
0
def register_extensions(app):
    db.init_app(app)
    mail.init_app(app)
    csrf_protect.init_app(app)
    migrate.init_app(app, db)
    bcrypt.init_app(app)