2021-09-27 12:03:35 +02:00
|
|
|
from flask import Flask, jsonify
|
|
|
|
from flask_jwt_extended import JWTManager
|
2021-10-22 10:37:42 +02:00
|
|
|
from flask_cors import CORS
|
2021-09-27 12:03:35 +02:00
|
|
|
|
2021-10-28 16:09:10 +02:00
|
|
|
from areas import api_v1
|
|
|
|
# There imports are required
|
|
|
|
from areas import users
|
|
|
|
from areas import apps
|
|
|
|
from areas import auth
|
2021-09-27 12:03:35 +02:00
|
|
|
from config import *
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
cors = CORS(app)
|
|
|
|
app.config['SECRET_KEY'] = SECRET_KEY
|
|
|
|
app.register_blueprint(api_v1)
|
|
|
|
|
|
|
|
jwt = JWTManager(app)
|
|
|
|
|
|
|
|
|
|
|
|
# When token is not valid or missing handler
|
|
|
|
@jwt.invalid_token_loader
|
|
|
|
@jwt.unauthorized_loader
|
|
|
|
@jwt.expired_token_loader
|
|
|
|
def expired_token_callback(*args):
|
|
|
|
return jsonify({'errorMessage': 'Unauthorized'}), 401
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def index():
|
|
|
|
return 'Open App Stack API v1.0'
|