<filename>app.py
from flask import Flask, jsonify
from flask_restful import Api
from blacklist import BLACKLIST
from resources.hotel import Hoteis,Hotel
from resources.user import User, UserRegister, UserLogin, UserLogout
from flask_jwt_extended import JWTManager
from blacklist import BLACKLIST
from sql_alchemy import banco



app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///banco.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['JWT_SECRET_KEY'] = 'DontTellAnyone'
app.config['JWT_BLACKLIST_ENABLED'] = True

api = Api(app)
jwt = JWTManager(app)
banco.init_app(app)


@app.before_first_request
def create_database():
    banco.create_all()
    
@jwt.token_in_blocklist_loader
def verify_blocklist(self, token):
    return token['jti'] in BLACKLIST

@jwt.revoked_token_loader
def access_token_invalid(jwt_header, jwt_payload):
    return jsonify({'mensage':'You have been logged out'}), 401 #unauthorized

    

api.add_resource(Hoteis, '/hoteis')
api.add_resource(Hotel,'/hoteis/<string:hotel_id>')
api.add_resource(User,'/usuarios/<int:user_id>')
api.add_resource(UserRegister, '/cadastro')
api.add_resource(UserLogin, '/login')
api.add_resource(UserLogout, '/logout')


if __name__ == '__main__':
#    from sql_alchemy import banco
    
#    banco.init_app(app)
    app.run(debug=False)
    

<filename>app.py
from flask import Flask, jsonify
from flask_restful import Api
from blacklist import BLACKLIST
from resources.hotel import Hoteis,Hotel
from resources.user import User, UserRegister, UserLogin, UserLogout
from flask_jwt_extended import JWTManager
from blacklist import BLACKLIST
from sql_alchemy import banco



app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///banco.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['JWT_SECRET_KEY'] = 'DontTellAnyone'
app.config['JWT_BLACKLIST_ENABLED'] = True

api = Api(app)
jwt = JWTManager(app)
banco.init_app(app)


@app.before_first_request
def create_database():
    banco.create_all()
    
@jwt.token_in_blocklist_loader
def verify_blocklist(self, token):
    return token['jti'] in BLACKLIST

@jwt.revoked_token_loader
def access_token_invalid(jwt_header, jwt_payload):
    return jsonify({'mensage':'You have been logged out'}), 401 #unauthorized

    

api.add_resource(Hoteis, '/hoteis')
api.add_resource(Hotel,'/hoteis/<string:hotel_id>')
api.add_resource(User,'/usuarios/<int:user_id>')
api.add_resource(UserRegister, '/cadastro')
api.add_resource(UserLogin, '/login')
api.add_resource(UserLogout, '/logout')


if __name__ == '__main__':
#    from sql_alchemy import banco
    
#    banco.init_app(app)
    app.run(debug=False)
    

#unauthorized #    from sql_alchemy import banco #    banco.init_app(app)