Esempio n. 1
0
def initialize_app(flask_app):
    configure_app(flask_app)

    blueprint = Blueprint('api', __name__, url_prefix='/api')
    api.init_app(blueprint)
    api.add_namespace(ns_user)
    api.add_namespace(ns_company)
    flask_app.register_blueprint(blueprint)

    db.init_app(flask_app)
Esempio n. 2
0
def create_app():
    app = Flask(__name__)

    from models.model import db
    db.init_app(app)

    app.config.from_object('config.DevelopConfig')

    app.register_blueprint(blueprint)
    with app.app_context():
        db.create_all()
    return app
Esempio n. 3
0
def create_app():
    app = Flask(__name__)
    app.config.from_pyfile("env.py")

    if app.config["ENV"] == "DEV":
        from flask_cors import CORS
        CORS(app, resources={r"/quotes/*": {"origins": "*"}})

    from models.model import db
    db.init_app(app)

    from blueprints.quotes import quotes
    app.register_blueprint(quotes)

    from blueprints.system import system
    app.register_blueprint(system)

    return app
Esempio n. 4
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(DefaultConfig)

    from models.model import db, login_manager

    bootstrap.init_app(app)
    db.init_app(app)
    db.PREFIX = app.config["DB_PREFIX"]

    app.site = {}

    def site_context_processor():
        return dict(site=app.site)

    app.context_processor(site_context_processor)
    check_start(app, db)

    login_manager.init_app(app)

    from app.web import web
    app.register_blueprint(web)

    from app.admin import admin
    app.register_blueprint(admin, url_prefix="/admin")

    from app.api import api
    app.register_blueprint(api, url_prefix="/api")

    template_filters(app)

    login_manager.login_view = "admin.login"
    login_manager.login_message = "请先登录!!!"

    from app.log import init_logging
    init_logging(app)

    return app
Esempio n. 5
0
def create_app(app_name=__name__, environment='local', storage='postgres'):
    app = Flask(app_name)

    if environment == 'test':
        app.config.from_object('config.TestConfig')
    else:
        app.config.from_object('config.DeployConfig')

    from models.model import db
    db.init_app(app)

    CORS(app)
    api = Api(app)

    quote_repository = QuotePostgresRepository(
    ) if storage == 'postgres' else QuoteRedisRepository(
        environment=environment)

    api.add_resource(Healthcheck, '/')
    api.add_resource(Quote,
                     '/quotes',
                     resource_class_kwargs={'repository': quote_repository})

    return app
Esempio n. 6
0
# coding=utf-8
from flask import Flask, render_template, jsonify
from flask_admin import Admin, BaseView, expose
from flask_login import LoginManager

from models.model import db, User
from config import config

app = Flask(__name__)
app.config.from_object(config)

admin = Admin(app, name='后台管理', template_mode='bootstrap3')
db.init_app(app)

login_manager = LoginManager()
login_manager.init_app(app)


class Main(BaseView):
    @expose('/')
    def main(self):
        return self.render('admin/main.html')


admin.add_view(Main(name='方案', endpoint='main', category='系统管理'))
admin.add_view(Main(name='登录', endpoint='login', category='用户管理'))


@app.route('/', methods=['GET', 'POST'])
def index():
    users = User.query.all()