def main(): core = os.environ["CORE"] db_path = os.path.join(core, "backend/database.db") os.environ["DATABASE_FILE_PATH"] = f"/{db_path}" app = Flask(__name__) app.app_context().push() init_app(app) db.create_all() print("seeding admin users") seed_admins(db, "users.tsv") print("seeding lifts") seed_class(db, "lifts.tsv", Lift)
def client(): """ Create a wrapped flask app. This is used for unittests that want to mock out all underlying singletons (such as DBs). Assumes that app.security has been set. """ from flask import Flask from src.app import init_app from src.models import User, Role from .test_utils import WrapApp app = Flask("testing") init_app(app, ":memory:", "secret key foo", "password salt bar") app.config["TESTING"] = True bmock = Mock() return WrapApp(app, User, Role, mocks={"blog_mock": bmock})
def main(): """ Standalone server startup script """ app = init_app() web.run_app( app, host=settings.HOST, port=settings.PORT, )
from src.app import app, init_app if __name__ == "__main__": init_app(app) app.run(debug=True)
from src.app import application, init_app init_app(application) if __name__ == '__main__': application.debug = True #init_app(application) application.run(host='0.0.0.0', port=5003)
from src.app import init_app app = init_app()
async def create_app(): """ Application factory used by gunicorn """ app = init_app() return app
import os from src.app import init_app if __name__ == '__main__': ##retrieve the environment variable from the terminal env_name = os.getenv('FLASK_ENV') app = init_app(env_name) ## run the app app.run()
import asyncio from src.app import init_app if __name__ == '__main__': asyncio.run(init_app())