import os import flask from flask import request, current_app, url_for from jinja2 import Template from app import create_app, db from app.models import User, Post, Tag, Category, Feedback from flask_script import Manager, Shell from flask_migrate import MigrateCommand app = create_app(os.getenv('FLASK_ENV') or 'config.DevelopementConfig') manager = Manager(app) @manager.command def faker(): print("Команда для добавления поддельных данных в таблицы") def shell_context(): import sys return {'app': app, 'os': os, 'sys': sys, 'flask': flask, 'request': request, 'current_app': current_app, 'url_for': url_for, 'Template': Template, 'db': db, 'User': User, 'Post': Post, 'Tag': Tag, 'Category': Category, 'Feedback': Feedback} manager.add_command("shell", Shell(make_context=shell_context)) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()