コード例 #1
0
def create_app():
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{basedir}/db.sqlite"
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    db.init_app(app)
    ma.init_app(app)

    if not (basedir / (__file__[:-2] + "sqlite")).exists():
        with app.app_context():
            db.create_all()

    return app
コード例 #2
0
def create_app(config=DevelopmentConfig):

    app = Flask(__name__)

    app.config.from_object(config)
    db.init_app(app)
    ma.init_app(app)

    with app.app_context():
        db.create_all()

    for url, blueprint in ACTIVE_ENDPOINTS:
        app.register_blueprint(blueprint, url_prefix=url)

    return app
コード例 #3
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    app.config['JWT_BLACKLIST_ENABLED'] = True
    config[config_name].init_app(app)
    jwt.init_app(app)
    db.init_app(app)
    ma.init_app(app)
    with app.app_context():
         db.create_all() #creats all table from model class
    app.register_blueprint(product_routes, url_prefix='/api/products')
    app.register_blueprint(user_routes, url_prefix='/api/users')

    
    # attach routes and custom error pages here
    return app
    
コード例 #4
0
ファイル: __init__.py プロジェクト: DiegoPuin/TiendaVirtual
def create_app(config=DevelopmentConfig):
    app = Flask(__name__)
    migrate = Migrate(app, db)
    csrf = CSRFProtect(app)
    app.config.from_object(config)

    db.init_app(app)
    ma.init_app(app)
    csrf.init_app(app)

    with app.app_context():
        db.create_all()

    # register each active blueprint
    for url, blueprint in ACTIVE_ENDPOINTS:
        app.register_blueprint(blueprint, url_prefix=url)

    return app
コード例 #5
0
def create_app(name=__name__):
    app = Flask(name)
    app.config.from_object('config')

    Bootstrap(app)
    app.register_blueprint(api, url_prefix='/api')
    # app.register_blueprint(editor, url_prefix='/editor')
    app.register_blueprint(portal)
    app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True

    db.init_app(app)
    ma.init_app(app)  # must initialize after SQLAlchemy

    CORS(app)

    basic_auth.init_app(app)

    return app
コード例 #6
0
from resources.stock import Stock, Stocks
from resources.watched import Watched, Watchlist

# Init app
app = Flask(__name__)
api = Api(app)

# Database
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
    'DATABASE_URL', 'mysql+pymysql://root:password@localhost/tickr')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

# JSON Web Token
app.config['SECRET_KEY'] = 'thisissecret'

ma.init_app(app)
jwt = JWTManager(app)

api.add_resource(User, "/user")
api.add_resource(UserRegistration, "/registration")
api.add_resource(UserLogin, "/login")
api.add_resource(Position, '/position/<int:_id>')
api.add_resource(Portfolio, '/portfolio')
api.add_resource(Stock, '/stock/<string:ticker>')
api.add_resource(Stocks, '/stocks')
api.add_resource(Watched, '/watch/<string:ticker>')
api.add_resource(Watchlist, '/watchlist')

# Run Server
if __name__ == '__main__':
    db.init_app(app)