from myapi.app import create_app app = create_app() if __name__ == "__main__": app.run(host="localhost", port=8080, use_reloader=False)
def app(): app = create_app(testing=True) return app
def app(): load_dotenv(".testenv") app = create_app(testing=True) return app
def app(): app = create_app(config_object=config.TestingConfig) with app.app_context(): yield app
from myapi.app import create_app from myapi import config application = create_app(config_object=config.ProductionConfig) if __name__ == '__main__': application.run()
import os from myapi.app import create_app application = create_app()
def app(): _app = create_app(testing=True) ctx = _app.test_request_context() ctx.push() yield _app ctx.pop()
def client(): _app = create_app(testing=True) _client = _app.test_client() yield _client
def create_myapi(info): return create_app(cli=True)
import os from myapi.app import create_app, db from myapi.models.users import Users from flask_script import Manager, Shell #===Импортируем переменные окружения из файла anyfile.env if os.path.exists('.env'): print('Importing environment from .env...') for line in open('.env'): var = line.strip().split('=') if len(var) == 2: os.environ[var[0]] = var[1] #===Запускаем прибожение app = create_app(os.getenv('FLASK_CONFIG') or 'development') manager = Manager(app) newUser = { 'userID':123, 'name': 'roma', 'url': 'ruls', 'loginType': 'FB', 'email': 'email', 'osUserName': '******', 'password': '******', 'accesToken': 'accessToken', } def make_shell_context(): return dict(app=app, db=db, Users=Users, newUser=newUser) @manager.command