#!/usr/bin/env python3 # -*- coding: utf-8 -*- # filename: manage.py # modified: 2019-10-25 import unittest from werkzeug.serving import run_simple from flask_script import Manager from app import create_app, db from app.models import MODELS manager = Manager() manager.app = create_app("development") @manager.shell def shell(): """ Run ipython shell """ return dict({ "app": manager.app, "db": db, }, **MODELS) @manager.option("-h", "--host", dest="host", default="127.0.0.1") @manager.option("-p", "--port", dest="port", default=7073) def runserver(host, port): """ Run development server """ app = manager.app run_simple(host, port, app,
start_ipython(argv=sys.argv[2:], user_ns=ctx) @manager.option("-h", "--host", dest="host", default="127.0.0.1") @manager.option("-p", "--port", dest="port", default=7072) @manager.option("--no-proxy-fix", dest="no_proxy_fix", action="store_true", default=False) def runserver(host, port, no_proxy_fix): """ run development server """ app = manager.app if not no_proxy_fix: app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1) run_simple(host, port, app, use_reloader=True, use_debugger=True) @manager.command def test(): """ run unittests """ tests = unittest.TestLoader().discover("test/unit/") unittest.TextTestRunner(verbosity=2).run(tests) if __name__ == '__main__': if len(sys.argv) >= 2 and sys.argv[1] in CONFIGS: env = sys.argv.pop(1) else: env = "development" manager.app = create_app(env) manager.run()
#!/usr/bin/env python # -*- coding: utf-8 -*- from flask_script import Manager from flask.ext.migrate import Migrate, MigrateCommand from momeet.app import create_app, db manager = Manager(create_app) if __name__ == '__main__': migrate = Migrate(manager.app(), db) manager.add_command('db', MigrateCommand) manager.run()