import base import os import logging import sys # Import the next_backend app from next_backend. env = os.environ.get('NEXT_FRONTEND_ENV', 'prod') app = base.create_app('base.settings.%sConfig' % env.capitalize(), env=env) # Log to standard out. Remember to turn off in production app.logger.addHandler(logging.StreamHandler(sys.stdout)) app.logger.setLevel(logging.DEBUG)
# -*- coding: utf-8 -*- from base import create_app import os import settings from slash import slash_bp from backoffice import backoffice_bp from tqueue import tq_bp from api import api_bp import jinja2 this_path = os.path.dirname(os.path.realpath(__file__)) TEMPLATE_FOLDER = os.path.join(this_path, 'templates') application = create_app(__name__) my_loader = jinja2.ChoiceLoader([ application.jinja_loader, jinja2.FileSystemLoader(TEMPLATE_FOLDER), jinja2.FileSystemLoader( os.path.join(this_path, 'lib/flask_bootstrap/templates')) ]) application.jinja_loader = my_loader application.register_blueprint(slash_bp) application.register_blueprint(tq_bp, url_prefix='/tqueue') application.register_blueprint(api_bp, url_prefix='/api') application.register_blueprint(backoffice_bp, url_prefix='/backoffice') if settings.TESTBED_ACTIVE: from testbed import testbed_bp
from base import create_app app = create_app() app.run(debug=True)
from base import create_app app = create_app() app.app_context().push() ENV = 'prod' if ENV == 'dev': app.debug = True else: app.debug = False if __name__ == '__main__': app.run()
#!/usr/bin/env python import os from flask.ext.script import Manager, Server from flask.ext.script.commands import ShowUrls, Clean from base import create_app from base.extensions import db # default to dev config because no one should use this in # production anyway env = os.environ.get("NEXT_FRONTEND_ENV", "dev") app = create_app("base.settings.%sConfig" % env.capitalize(), env=env) manager = Manager(app) manager.add_command("server", Server(host="0.0.0.0", port=8002)) manager.add_command("show-urls", ShowUrls()) manager.add_command("clean", Clean()) @manager.shell def make_shell_context(): """ Creates a python REPL with several default imports in the context of the app """ return dict(app=app, db=db, User=User) if __name__ == "__main__": manager.run()
from base import create_app app = create_app("copernicus.cfg") if __name__ == "__main__": app.run(debug=True, use_debugger=False, use_reloader=False, passthrough_errors=True)
import os from base import create_app, db from flask_script import Manager from flask_migrate import Migrate, MigrateCommand app = create_app(os.getenv('THERMOS_ENV') or 'dev') # Manager/Manage.py setup. ToDo: Upgrade to Click/Flask CLI manager = Manager(app) # Need to pass the app AND the db object. migrate = Migrate(app, db) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run() # For when migrations don't go so well. # @manager.command # def insert_data(): # dave = User(username="******", email="*****@*****.**", password="******") # db.session.add(dave) # sarah = User(username="******", email="*****@*****.**", password="******") # db.session.add(sarah) # karl = User(username="******", email="*****@*****.**", password="******") # db.session.add(karl) # # # @manager.command # def dropdb():
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys # 引用sys模块进来,并不是进行sys的第一次加载 reload(sys) # 重新加载sys sys.setdefaultencoding('utf8') import config from base import create_app app = create_app(__name__, config, template_folder='template', static_folder='static') # # if __name__ == '__main__': app.run(host='0.0.0.0', port=8011, debug=True)
def create_app(self): return base.create_app('test')
# -*- coding:utf-8 -*- # Created by mark.huang on 2019/6/25 from base import create_app, db from flask_script import Manager, Shell from flask_migrate import Migrate, MigrateCommand import os app = create_app(os.getenv('MBS_CONFIG') or 'default') manager = Manager(app) migrate = Migrate(app, db) def make_shell_context(): return dict(app=app, db=db) manager.add_command('shell', Shell(make_shell_context)) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
from sklearn.externals import joblib from base import KeyValueModel, create_app class IrisModel(KeyValueModel): name = 'iris' probability = True pipeline = joblib.load('models/iris.pickle') schema = [{ 'name': 'sepal_length' }, { 'name': 'sepal_width' }, { 'name': 'petal_length' }, { 'name': 'petal_width' }] # fields = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width'] app = create_app([IrisModel()])