Ejemplo n.º 1
0
 def create_app(self):
     app = Flask(__name__)
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://"
     app.config['TESTING'] = True
     # app.config['SQLALCHEMY_ECHO'] = True
     app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
     db.init_app(app)
     return app
Ejemplo n.º 2
0
def main():
    '''
    This method registers all the end points of the application
    '''
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    api = Api(app)

    @app.before_first_request
    def create_tables():
        db.create_all()

    api.add_resource(UserHandler, '/api/user', '/api/user/<string:name>')
    api.add_resource(AddressHandler, '/api/address',
                     '/api/address/<string:id>')
    api.add_resource(CourseHandler, '/api/course', '/api/course/<string:name>')
    api.add_resource(StudentHandler, '/api/student',
                     '/api/student/<string:id>')

    from database.config import db
    db.init_app(app)
    app.run(debug=False)
Ejemplo n.º 3
0
    app.config['TOKEN_SECRET'] = config.get('App', 'TOKEN_SECRET')
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///sqlite.db'
elif os.environ.get('ENV_MODE', None) is not None:
    app.config['GOOGLE_ID'] = os.environ['GOOGLE_ID']
    app.config['GOOGLE_SECRET'] = os.environ['GOOGLE_SECRET']
    app.config['TOKEN_SECRET'] = os.environ['TOKEN_SECRET']
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
else:
    raise ValueError('environment variables not set or file not exists', BASE_DIR, secretPath)

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

app.debug = True
app.secret_key = 'development'

db.init_app(app)
migrate = Migrate(app, db)

manager = Manager(app)
manager.add_command('db', MigrateCommand)

login_manager.init_app(app)

app.register_blueprint(login_api)
app.register_blueprint(account_api)
app.register_blueprint(transaction_api)
app.register_blueprint(category_api)
app.register_blueprint(currency_api)
app.register_blueprint(cycle_api)
app.register_blueprint(auth_api)