def create_app(): # creates the app app = Flask(__name__, static_folder='../static/dist', template_folder='../static/templates') # config devConfig = Path(os.path.join(app.instance_path, 'devConfig.py')) prodConfig = Path(os.path.join(app.instance_path, 'prodConfig.py')) # dev over prod if devConfig.is_file(): from instance.devConfig import DevelopmentConfig app.config.from_object(DevelopmentConfig) elif prodConfig.is_file(): from instance.prodConfig import ProductionConfig app.config.from_object(ProductionConfig) # database with app.app_context(): db.init_app(app) db.create_all() # views with app.app_context(): from server import views # populates test database entries with app.app_context(): initialContent.insertAds() return app
def db(app, request): """The app database with fresh set of tables.""" _db.init_app(app) _db.drop_all() _db.create_all() return _db
def db(app): """A database for the tests.""" _db.app = app with app.app_context(): _db.create_all() yield _db # Explicitly close DB connection _db.session.close() _db.drop_all()
def create_app(): # creates the app app = Flask( __name__, static_folder=os.path.join(parent_dir, 'assets'), template_folder=os.path.join(parent_dir, 'templates'), ) # loads config config = Path(os.path.join(app.instance_path, 'config.py')) # dev config # from instance.config import dev_config # app.config.from_object(dev_config) # prod config from instance.config import prod_config app.config.from_object(prod_config) # views with app.app_context(): from server import views # projects from server.projects import api as projects_api app.register_blueprint(projects_api.bp) # tags from server.tags import api as tags_api app.register_blueprint(tags_api.bp) # post from server.post import api as post_api app.register_blueprint(post_api.bp) # databbase with app.app_context(): db.init_app(app) db.create_all() # test data with app.app_context(): from server.test_data import inject_test_data inject_test_data() return app
def app(database): """ Create a Flask app context for the tests. """ from main import app with app.app_context(): db.init_app(app) db.create_all() # migrate = Migrate(app, db) # api.init_app(app) yield app with app.app_context(): # clean up : revert DB to a clean state db.session.remove() db.session.commit() db.session.close_all() db.drop_all() db.engine.dispose()
def create_app(): # creates the app app = Flask(__name__, static_folder='../static/dist', template_folder='../static/templates') # configuration from instance.config import Configuration app.config.from_object(Configuration) # views with app.app_context(): from server import views from server import ai # database with app.app_context(): db.init_app(app) db.create_all() return app
def create_db(): db.create_all()
def setUpClass(cls): cls.context = server.app.test_request_context() cls.context.push() db.create_all()
def create_database(): app.logger.info('Creating Database...') db.create_all() app.logger.info('Database Created')
def db(app): _db.drop_all() _db.create_all() yield _db _db.drop_all()
#!flask/bin/python __author__ = 'Simon' from server.http import app from server.database import db if __name__ == '__main__': db.create_all() app.run(debug=True)