예제 #1
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)
    db.init_app(app)
    migrate.init_app(app, db)
    jwt.init_app(app)
    app.register_blueprint(routes_bp)
    app.db = db
    return app
from flask_praetorian import auth_required

from app import app, jwt
from src.main.model.user import User

jwt.init_app(app, User)


# Generate JWT to authenticate the user
def generate_jwt_token(email, password):
    return jwt.encode_jwt_token(jwt.authenticate(email, password))


# Generate refreshed JWT
def get_jwt_token_refresh():
    return jwt.refresh_jwt_token(jwt.read_token_from_header())


@auth_required
def auth_func(**kwargs):
    pass
예제 #3
0
from app import app, ImageFile, db_engine, jwt, user_bp, task_bp, polygon_bp, image_bp, label_bp
from flask_mongoengine.json import override_json_encoder
import os
from flask_cors import CORS
import meinheld

meinheld.set_max_content_length(2**10 * 2**10 * 2**10 * 1)  #1GB

if os.path.isfile("app/instance/config.local.cfg"):
    app.config.from_pyfile(os.path.abspath("app/instance/config.local.cfg"))
else:
    app.config.from_pyfile(os.path.abspath("app/instance/config.cfg"))
override_json_encoder(app)
db_engine.init_app(app)
jwt.init_app(app)
app.register_blueprint(user_bp)
app.register_blueprint(task_bp)
app.register_blueprint(polygon_bp)
app.register_blueprint(image_bp)
app.register_blueprint(label_bp)
CORS(app, resources={r'/*': {'origins': '*'}})

if __name__ == '__main__':
    app.run(port=os.environ.get("PORT", 80), debug=True)
예제 #4
0
from flask_praetorian import auth_required

from app import app, jwt
from src.main.model.staff import Staff


jwt.init_app(app, Staff)


def generate_jwt_token(email, password):
    return jwt.encode_jwt_token(
            jwt.authenticate(email, password)
        )


def get_jwt_token_refresh():
    return jwt.refresh_jwt_token(jwt.read_token_from_header())


@auth_required
def auth_func(**kwargs):
    pass