from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_oauthlib.client import OAuth

from config import config

db = SQLAlchemy()
lm = LoginManager()
oauth = OAuth()


def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    db.init_app(app)
    lm.init_app(app)
    oauth.init_app(app)

    from app.views import views
    app.register_blueprint(views)

    return app
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_oauthlib.client import OAuth

from config import config

db = SQLAlchemy()
oauth = OAuth()
lm = LoginManager()
lm.login_view = "views.login"

from app.models import User


@lm.user_loader
def load_user(id):
    return User.query.get(int(id))

def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    db.init_app(app)
    lm.init_app(app)
    oauth.init_app(app)

    from app.views import views
    app.register_blueprint(views)

    return app
Set user loader and login view
Set user loader and login view

  from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  from flask_login import LoginManager
  from flask_oauthlib.client import OAuth
  
  from config import config
  
  db = SQLAlchemy()
+ oauth = OAuth()
  lm = LoginManager()
- oauth = OAuth()
+ lm.login_view = "views.login"
  
+ from app.models import User
+ 
+ 
+ @lm.user_loader
+ def load_user(id):
+     return User.query.get(int(id))
  
  def create_app(config_name):
      app = Flask(__name__)
      app.config.from_object(config[config_name])
  
      db.init_app(app)
      lm.init_app(app)
      oauth.init_app(app)
  
      from app.views import views
      app.register_blueprint(views)
  
      return app
Set user loader and login view
## Code Before:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_oauthlib.client import OAuth

from config import config

db = SQLAlchemy()
lm = LoginManager()
oauth = OAuth()


def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    db.init_app(app)
    lm.init_app(app)
    oauth.init_app(app)

    from app.views import views
    app.register_blueprint(views)

    return app
## Instruction:
Set user loader and login view
## Code After:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_oauthlib.client import OAuth

from config import config

db = SQLAlchemy()
oauth = OAuth()
lm = LoginManager()
lm.login_view = "views.login"

from app.models import User


@lm.user_loader
def load_user(id):
    return User.query.get(int(id))

def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    db.init_app(app)
    lm.init_app(app)
    oauth.init_app(app)

    from app.views import views
    app.register_blueprint(views)

    return app