示例#1
0
def create_app(test_config=None):
    # create and configure the app
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(
            # a default secret that should be overridden by instance config
            SECRET_KEY='dev',
    )

    if test_config is None:
        # load the instance config, if it exists, when not testing
        app.config.from_pyfile('config.py', silent=True)
    else:
        # load the test config if passed in
        app.config.from_mapping(test_config)

    # ensure the instance folder exists
    try:
        os.makedirs(app.instance_path)
    except OSError:
        pass

    app.register_blueprint(auth.bp)
    app.register_blueprint(tournament.bp)
    app.register_blueprint(team.bp)
    app.register_blueprint(games.bp)
    db.init_app(app)

    return app
示例#2
0
def client():
    app = create_app(config_class='config.TestingConfig')

    client = app.test_client()

    with app.app_context():
        db.init_app(app)
        db.create_all()
        yield client
        db.drop_all()
示例#3
0
def create_app():
    app = Flask(__name__, static_folder='static')
    configure_app(app)

    db.init_app(app)

    with app.app_context():
        db.init_db()
        from project import routes  # noqa: F401

    return app
    def create_app(self):
        app = Flask(__name__)

        jwt = JWTManager()

        app.config.from_object('project.config.TestConfig')

        db.init_app(app)
        jwt.init_app(app)

        app.register_blueprint(auth_blueprint)

        return app
示例#5
0
    def create_app(self):
        app = Flask(__name__)

        jwt = JWTManager()

        app.config.from_object('project.config.TestConfig')

        db.init_app(app)
        jwt.init_app(app)

        from project.api.planting_status.views import planting_status_blueprint
        from project.api.irrigation.views import irrigation_blueprint
        app.register_blueprint(planting_status_blueprint)
        app.register_blueprint(irrigation_blueprint)

        return app
示例#6
0
def create_app(test_config=None):
    """Create and configure an instance of the Flask application."""
    app = Flask(__name__, instance_relative_config=True)
    app.secret_key = 'learning'
    app.config['SESSION_TYPE'] = 'filesystem'
    sess = Session()

    # app.config.from_mapping(
    #     # a default secret that should be overridden by instance config
    #     SECRET_KEY='dev',
    #     # store the database in the instance folder
    #     DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'),
    # )

    # if test_config is None:
    #     # load the instance config, if it exists, when not testing
    #     app.config.from_pyfile('config.py', silent=True)
    # else:
    #     # load the test config if passed in
    #     app.config.update(test_config)

    # # ensure the instance folder exists
    # try:
    #     os.makedirs(app.instance_path)
    # except OSError:
    #     pass

    @app.route('/hello')
    def hello():
        return 'Hello, World!'

    # register the database commands
    from project import db
    db.init_app(app)

    # # apply the blueprints to the app
    from project import routes
    app.register_blueprint(routes.bp)
    # app.register_blueprint(blog.bp)

    # make url_for('index') == url_for('blog.index')
    # in another app, you might define a separate main index here with
    # app.route, while giving the blog blueprint a url_prefix, but for
    # the tutorial the blog will be the main index
    app.add_url_rule('/', endpoint='index')

    return app
示例#7
0
def create_app(test_config=None):
    """Create and configure an instance of the Flask application."""
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_mapping(
        # a default secret that should be overridden by instance config
        SECRET_KEY="dev",
        # store the database in the instance folder
        DATABASE=os.path.join(app.instance_path, "project.sqlite"),
    )

    if test_config is None:
        # load the instance config, if it exists, when not testing
        app.config.from_pyfile("config.py", silent=True)
    else:
        # load the test config if passed in
        app.config.update(test_config)

    # ensure the instance folder exists
    try:
        os.makedirs(app.instance_path)
    except OSError:
        pass

    @app.route("/hello")
    def hello():
        return "Hello, World!"

    # register the database commands
    from project import db

    db.init_app(app)

    # apply the blueprints to the app
    from project import accounts, message, posts, voting

    app.register_blueprint(accounts.bp)
    app.register_blueprint(message.bp)
    app.register_blueprint(posts.bp)
    app.register_blueprint(voting.bp)

    return app
示例#8
0
from project import create_app
from project import db
from flask_login import UserMixin
from .models import User, Session_tracking, Mails

app = create_app()

with app.test_request_context():
    db.init_app(app)
    db.create_all()
    print("Baza aplikacji została założona")
示例#9
0
from flask import Flask
 
app = Flask(__name__)
 
app.secret_key = 'development key'

app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://*****:*****@localhost/pisDB'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
 
from project import db
db.init_app(app)