def setUp(self): """Define test variables and initialize app.""" self.app = create_app(config_name="testing") self.client = self.app.test_client # binds the app to the current context with self.app.app_context(): DB.init_app(self.app) # create all tables DB.create_all()
# logger.info("Hello") # return "I am mutuba" # @celery.task() # def add_together(a, b): # return a + b import click from instance import ( create_app, celery, ) from instance import tasks app = create_app() @app.shell_context_processor def make_shell_context(): # Exports for `flask shell` return { # 'app' is exported automagically 'celery': celery, } @app.cli.command() @click.argument('a') @click.argument('b') def add(a, b):
from app.auth.model.tag import Tag from app.auth.model.category import Category from app.auth.model.product import Product from app.auth.model.author import Author from app.auth.model.book import Book from app.auth.model.mutuba import Mutuba from app.auth import blueprint from app.me.route.home import home_api from app.me_2.route.home import home_api2 app = create_app(os.getenv('APP_SETTINGS')) app.register_blueprint(blueprint) app.register_blueprint(home_api, url_prefix='/api1') app.register_blueprint(home_api, url_prefix='/api2') app.app_context().push() manager = Manager(app)
#!/usr/bin/env python # -*- coding:utf-8 -*- import os import datetime from flask_script import Manager, Shell from flask_migrate import Migrate, MigrateCommand from instance.models import User from instance import db, create_app app = create_app('dev') app.secret_key = os.urandom(24) app.permanent_session_lifetime = datetime.timedelta(seconds=24 * 60 * 60) manager = Manager(app) migrate = Migrate(app, db) def make_shell_context(): return dict(app=app, User=User, db=db) manager.add_command("shell", Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
# -*- coding: utf-8 -*- """ Generate the manager to be used to the database migrations. Creates a new command line option 'db' for the migrate command. Use: python migrate.py db """ import os from flask_migrate import Migrate, MigrateCommand from flask_script import Manager # class for handling a set of commands from instance import create_app from db import DB from . import * # pylint: disable=wildcard-import APP = create_app(config_name=os.getenv('APP_SETTINGS'), database=DB) MIGRATE = Migrate(APP, DB) MANAGER = Manager(APP) MANAGER.add_command('db', MigrateCommand) if __name__ == '__main__': MANAGER.run()
# -*- coding: utf-8 -*- """ Create the main application. Create the main application using the development setting as default also initialize the database. The database is populated on the endpoint _init_db that is used with a POST to the proper url and with the header Authorization Bearer base64(username + password) """ import os from flask_cors import CORS from db import DB from instance import create_app APP = create_app(os.getenv("APP_SETTINGS"), database=DB) CORS(APP) DB.init_app(APP) if __name__ == '__main__': APP.run()
from instance import create_app app = create_app(config_name='testing') from api.views import appblueprint, authblueprint app.register_blueprint(appblueprint, url_prefix='/api/') app.register_blueprint(authblueprint, url_prefix='/api/')
import os from instance import create_app from flask_cors import CORS cors = CORS() app = create_app(config_name=os.getenv('CONFIG') or 'development') cors.init_app(app) from api.views.auth import authblueprint from api.views.workerOrders import appblueprint origins = app.config.get('CORS_ORIGIN_WHITELIST', '*') cors.init_app(appblueprint, origins=origins) cors.init_app(authblueprint, origins=origins) app.register_blueprint(appblueprint, url_prefix='/api/') app.register_blueprint(authblueprint, url_prefix='/api/')