def app(): app = create_app() yield app
#!/usr/bin/env python # -*- coding: utf-8 -*- """Manage for flaskapp.""" import os from flaskapp import create_app, db from flask_script import Manager from flask_migrate import Migrate, MigrateCommand app = create_app(os.getenv('FLASKAPP_ENV') or 'dev') manager = Manager(app) migrate = Migrate(app, db) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
from flaskapp import create_app application = create_app(app_config='DEVELOPMENT') if __name__ == '__main__': application.run()
from flaskapp import create_app app = create_app() if __name__ == "__main__": from werkzeug.serving import run_simple run_simple('0.0.0.0', 5000, app, threaded=True, use_reloader=True, use_debugger=True)
def test_config(): assert not create_app().testing assert create_app({'TESTING': True}).testing
from flaskapp import create_app if __name__ == '__main__': app = create_app(test_config=None) app.run(host='127.0.0.1', port=5000, debug=True)
from flaskapp import create_app import threading from telegram_bot import updater def flask_thread(): print('flask thread starting:') flask.run('0.0.0.0') def telegram_thread(): updater.start_polling() flask = create_app() if __name__ == '__main__': t1 = threading.Thread(target=flask_thread, name='flask-thread') # # t3 = threading.Thread(target=telegram_thread) t1.start() t1.join() # Main thread should be blocked
from flask_migrate import Migrate from flask_migrate import MigrateCommand from flask_script import Manager from flaskapp import create_app from flaskapp import db from flaskapp.config import DevelopmentConfig app = create_app(config_class=DevelopmentConfig) migrate = Migrate(app, db) manager = Manager(app) manager.add_command("db", MigrateCommand) if __name__ == "__main__": manager.run()
import sys, os sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from flaskapp import create_app from flaskapp.meta import db # create database tables with create_app().app_context(): db.create_all()
def test_flask_sample(): app = create_app() app.config['TESTING'] = True client = app.test_client() result = client.get('/') assert b'Hello, World' == result.data
from flask_migrate import Migrate from flask_migrate import MigrateCommand from flask_script import Manager from flaskapp import create_app from flaskapp import db from flaskapp.config import Config app = create_app(config_class=Config) migrate = Migrate(app, db) manager = Manager(app) manager.add_command("db", MigrateCommand) if __name__ == "__main__": manager.run()
import os from flaskapp import create_app, mongodb app = create_app(os.getenv("FLASK_CONFIG") or "default") @app.shell_context_processor def make_shell_context(): return dict(mongodb=mongodb)
from flaskapp import create_app, db # Instantiating app to create_app class in __init__.py file app = create_app() app.app_context().push() # Run Flask app in DEBUG MODE if __name__ == '__main__': db.create_all(app=create_app()) app.run(debug=True)
from flaskapp import create_app app = create_app() # create app instance # Run app only from within module (i.e. run.py) if __name__ == "__main__": app.run(debug=True)
def setUp(self): self.app = create_app("config.TestingConfig") self.client = self.app.test_client()
def create_app(self): from flaskapp import create_app from flaskapp.config import TestConfig app = create_app(TestConfig) return app
def setUpClass(cls): app = create_app() app.app_context().push()
def setUp(self): self.app = create_app()
def create_app(self): """Create Flask App.""" return create_app('test')
def create_wsgi() -> flask.Flask: auth_api = create_auth_api_client() resource_api = create_resource_api_client() http_handler = create_http_handler(auth_api, resource_api) return flaskapp.create_app(http_handler)
import os from flaskapp import create_app, db from flaskapp.models import User, Role from flask.ext.script import Manager, Shell from flask.ext.migrate import Migrate, MigrateCommand app = create_app(os.getenv('FLASK_CONFIG')) #app = create_app(os.getenv('default')) manager = Manager(app) migrate = Migrate(app, db) def make_shell_context(): return dict(app=app, db=db, User=User, Role=Role) manager.add_command("shell", Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
from flaskapp import create_app from flaskapp.config import DevelopmentConfig app = create_app(DevelopmentConfig) # If we do not want to set all enviroment variables to run the server. # We can wirte this code and run server using python command: # python flaskblog.py if __name__ == '__main__': app.run(debug=True)
from flaskapp import create_app app = create_app()
import os from flaskapp import create_app app = create_app(os.getenv(FLASK_CONFIG, default="config.DevelopmentConfig"))
from gevent import monkey monkey.patch_all() from flaskapp import create_app, socketio app = create_app(True) if __name__ == '__main__': socketio.run(app)
def create_wsgi() -> flask.Flask: applications_repo = create_applications_repository() oauth2_service = create_oauth2_service(applications_repo) http_handler = create_http_handler(oauth2_service) return flaskapp.create_app(http_handler)