示例#1
0
def create_app():
    app = Flask('posyandu')

    app.config.from_pyfile('../common/app.cfg')
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config[
        'POSYANDU_SQLALCHEMY_DATABASE_URI']

    # binds mean that tables with bind_key will fetch from below uris
    app.config['SQLALCHEMY_BINDS'] = {
        'sideka': app.config['ADMIN_SQLALCHEMY_DATABASE_URI']
    }

    app.register_blueprint(UserController)
    app.register_blueprint(ParentController)
    app.register_blueprint(ChildController)
    app.register_blueprint(GrowthController)
    app.register_blueprint(DevelopmentController)
    app.register_blueprint(VaccineController)

    db.init_app(app)
    ma.init_app(app)
    CORS(app)

    with app.app_context():
        # bind=None means that only main database is auto-created
        db.create_all(bind=None)

    return app
示例#2
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(DebugConfig)
    api = Api(app)
    api.add_resource(Video, '/video','/video/<int:videoid>')
    db.init_app(app)
    return app
示例#3
0
def create_app():
    app = Flask('tatakelola')
    Compress(app)
    app.config.from_pyfile('../common/app.cfg')
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config[
        'TATAKELOLA_SQLALCHEMY_DATABASE_URI']

    # binds mean that tables with bind_key will fetch from below uris
    app.config['SQLALCHEMY_BINDS'] = {
        'sideka': app.config['ADMIN_SQLALCHEMY_DATABASE_URI'],
        'keuangan': app.config['KEUANGAN_SQLALCHEMY_DATABASE_URI']
    }

    app.register_blueprint(AdminController)
    app.register_blueprint(ApbdesController)
    app.register_blueprint(GeojsonController)
    app.register_blueprint(PendudukController)
    app.register_blueprint(RegionController)
    app.register_blueprint(SummaryController)
    app.register_blueprint(StatisticController)
    app.register_blueprint(LayoutController)
    app.register_blueprint(BoundaryController)

    db.init_app(app)
    ma.init_app(app)
    CORS(app)

    with app.app_context():
        # bind=None means that only main database is auto-created
        db.create_all(bind=None)

    return app
示例#4
0
def create_app():
    app = Flask('keuangan')

    app.config.from_pyfile('../common/app.cfg')
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config[
        'KEUANGAN_SQLALCHEMY_DATABASE_URI']

    # binds mean that tables with bind_key will fetch from below uris
    app.config['SQLALCHEMY_BINDS'] = {
        'sideka': app.config['ADMIN_SQLALCHEMY_DATABASE_URI']
    }

    app.register_blueprint(KegiatanController)
    app.register_blueprint(PenerimaanController)
    app.register_blueprint(PenganggaranController)
    app.register_blueprint(ProgressController)
    app.register_blueprint(RegionController)
    app.register_blueprint(BudgetController)
    app.register_blueprint(SppController)
    app.register_blueprint(LikelihoodController)
    app.register_blueprint(AdminController)

    db.init_app(app)
    ma.init_app(app)
    cache.init_app(app)
    CORS(app)

    with app.app_context():
        # bind=None means that only main database is auto-created
        db.create_all(bind=None)

    return app
示例#5
0
def create_app():
    app = Flask(__name__)
    app.config.from_pyfile('../common/app.cfg')
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config[
        'ADMIN_SQLALCHEMY_DATABASE_URI']
    app.config['SQLALCHEMY_BINDS'] = {
        'sideka': app.config['ADMIN_SQLALCHEMY_DATABASE_URI']
    }
    app.secret_key = app.config["SECRET_KEY"]
    CORS(app)
    db.init_app(app)
    ma.init_app(app)
    return app
示例#6
0
文件: app.py 项目: RRFreitas/TCC
#!/usr/bin/env python3
from flask import Flask, Blueprint
from flask_restful import Api
from flask_cors import CORS
from common.database import db
from resources.PessoaResource import PessoaResource
from resources.ReconhecedorResource import ReconhecedorResource
import sys
import os

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')

db.init_app(app)

api_bp = Blueprint('api', __name__)
api = Api(api_bp, prefix='/api')

api.add_resource(PessoaResource, '/pessoas', '/pessoas/<int:pessoa_id>')
api.add_resource(ReconhecedorResource, '/reconhecer')

app.register_blueprint(api_bp)

cors = CORS(app, resources={r"/api/*": {"origins": "*"}})


def run(host='0.0.0.0', debug=False):
    port = int(os.environ.get("PORT", 5000))
    app.debug = debug
    app.run(host=host, port=port)