def setUp(self): fd, self.filename = tempfile.mkstemp() os.write(fd, content) os.close(fd) config = { 'SQLALCHEMY_DATABASE_URI': 'sqlite:///' + self.filename, } self.app = create_app(config) self.client = self.app.test_client()
def app(): app = create_app({ 'TESTING': True, 'SQLALCHEMY_DATABASE_URI': 'postgresql+psycopg2://postgres:disastergram@test-db/postgres', 'SQLALCHEMY_TRACK_MODIFICATIONS': False, 'ENV': 'testing', 'PUBLIC_KEY': PUBLIC_KEY, 'PRIVATE_KEY': PRIVATE_KEY, 'SECRET_KEY': SECRET_KEY, }) init_db(app) yield app
def main(): app = create_app("production") CORS(app) @app.before_request def log_path(): logger.debug(">>> {0} - {1} {2}".format(request.remote_addr, request.method, request.path)) initialize_api_v1(app) while not redis_instance.wait_for_redis(): time.sleep(1) register_myself_in_redis_for_lymphocite() host = "0.0.0.0" logger.info( ">>>>> Starting server at http://{0}:5000/api/ <<<<<".format(host)) app.run(host=host, debug=app.config["FLASK_DEBUG"])
from auth import create_app app = create_app() if __name__ == '__main__': app.run(host='0.0.0.0', debug=True)
def setUp(self) : self.app = create_app() self.app_context = self.app.app_context() self.app_context.push() self.client = self.app.test_client() db.create_all()
def test_config(): assert not create_app().testing assert create_app({'TESTING': True}).testing
import os from flask_migrate import Migrate # from user import db, create_app from auth import db, create_app app = create_app(os.getenv('FLASK_CONFIG') or 'default') migrate = Migrate(app, db)
from auth import create_app application = create_app() if __name__ == "__main__": application.run()
def app(): return create_app('config_test')
#!/usr/bin/env python3 import os, importlib from flask.ext.script import Manager, Server from flask.ext.migrate import Migrate, MigrateCommand from auth import db, create_app config_module_name = os.getenv('FLASK_CONFIG', 'config_dev') config = importlib.import_module(config_module_name) app = create_app(config) migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) host = app.config.get('HOST', 'localhost') manager.add_command('runserver', Server(host=host)) if __name__ == '__main__': manager.run()