Exemplo n.º 1
0
def create_app():
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = "postgres:///userdb"
    db.init_app(app)
    ma.init_app(app)
    ctx = app.app_context()
    ctx.push()

    db.create_all()
    # db.drop_all()
    return app
Exemplo n.º 2
0
def create_app():
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = "postgres://*****:*****@localhost:5432/bookdb"
    db.init_app(app)
    ma.init_app(app)
    ctx = app.app_context()
    ctx.push()
    # db.drop_all()
    db.create_all()

    return app
    
Exemplo n.º 3
0
def create_app(settings_name):
    app = Flask(__name__)
    # app.config["SQLALCHEMY_DATABASE_URI"]="postgres:///cardb"
    db.init_app(app)
    ma.init_app(app)
    migrate.init_app(app, db)
    settings_obj = get_settings(settings_name)
    app.config.from_object(settings_obj)
    ctx = app.app_context()
    ctx.push()
    # db.create_all()
    return app
Exemplo n.º 4
0
def create_app(settings_name):
    app = Flask(__name__)
    db.init_app(app)
    ma.init_app(app)
    migrate.init_app(app, db)
    app.config['JWT_SECRET_KEY'] = 'test'
    jwt.init_app(app)
    settings_obj = get_settings(settings_name)
    app.config.from_object(settings_obj)
    ctx = app.app_context()
    ctx.push()

    return app
Exemplo n.º 5
0
def createAp(settings_name):
    app = Flask(__name__)
    handler = logging.StreamHandler(sys.stdout)
    settings_obg = get_settings(settings_name)
    app.config.from_object(settings_obg)
    app.logger.addHandler(handler)
    migrate = Migrate(app, db)
    jwt.init_app(app)
    db.init_app(app)
    ma.init_app(app)
    ctx = app.app_context()
    ctx.push()
    return app
Exemplo n.º 6
0
    db.create_all()


@app.errorhandler(MyException)
def handle_error(err):
    return err.error_to_dict(), err.status_code


api.add_resource(Login, '/auth/login')
api.add_resource(UserInfo, '/user/signup')
api.add_resource(UsersList, '/users')
api.add_resource(UserIdentity, '/current_user')
api.add_resource(UserOperation, '/user/<int:id>')
api.add_resource(UserUpdate, '/user/update')
api.add_resource(RoleUpdate, '/user/role_update')
api.add_resource(PasswordChange, '/user/change_password')
api.add_resource(PasswordForgot, '/forgot_password')
api.add_resource(RefreshAccessToken, '/refresh_access_token')
api.add_resource(EmailToken, '/email_token')
api.add_resource(EmailVerify, '/verify_email')
api.add_resource(EmailUpdateToken, '/email/update_token')
api.add_resource(EmailUpdate, '/email/update')

api.add_resource(Logout, '/logout')

if __name__ == '__main__':
    db.init_app(app)
    jwt.init_app(app)
    mail.init_app(app)
    app.run(debug=True)