Exemplo n.º 1
0
Arquivo: app.py Projeto: datstar2/BACK
def create_app(test_config=None):
    app = Flask(__name__)

    CORS(app)

    app.config['CORS_HEADERS'] = 'Content-Type'

    if test_config is None:
        app.config.from_pyfile("config.py")
    else:
        app.config.update(test_config)

    app.config['SQLALCHEMY_DATABASE_URI'] = config.DB_URL
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    db.init_app(app)

    app.app_context().push()

    ## Persistenace Layer
    user_dao = UserDAO(db)
    tag_dao = TagDAO(db)
    image_dao = ImageDAO(db)
    model_dao = ModelDAO(db)
    test_dao = testDAO(db)
    model_controller = ModelController(model_dao)


    print("APP실행중")

    # ## Threading_Timer


    print("쓰레드 실행 뒤")



    ## Business Layer
    s3_client = boto3.client(
        "s3",
        aws_access_key_id     = app.config['S3_ACCESS_KEY'],
        aws_secret_access_key = app.config['S3_SECRET_KEY']
    )


    services = Services
    services.user_service = UserService(user_dao, app.config)
    services.tag_service = TagService(tag_dao)
    services.image_service = ImageService(image_dao, app.config, s3_client, test_dao)
    services.model_service = ModelService(model_controller)


    ## 엔드포인트들을 생성
    create_endpoints(app, services)



    return app
Exemplo n.º 2
0
def create_app(app_name='TTX_API'):
    app = Flask(app_name)
    app.config.from_object('api.config.BaseConfig')

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

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

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

    return app
Exemplo n.º 3
0
def init_app(config):
    app = flask.Flask(__name__)

    app.config.from_object(config)

    app.json_encoder = FlaskCustomJSONEncoder

    db.init_app(app)

    if not app.testing:
        logging.basicConfig(level=logging.INFO)

    app.register_blueprint(blueprint=blueprint, url_prefix='/')

    # Sentry - only for production

    # Todo uncomment this if you have a sentry DSN
    # if not app.debug and not app.testing and 'SENTRY_DSN' in app.config:
    #     from raven.contrib.flask import Sentry
    #     Sentry(app)

    @app.errorhandler(ClientException)
    def handle_client_errors(error):
        response = flask.jsonify(error.to_dict())
        response.status_code = error.status_code
        return response

    with app.app_context():
        db.create_all()

        my_injector = Injector([
            ServiceModule,
            FactoryModule,
            PersonRepositoryModule
        ])

        FlaskInjector(app=app, injector=my_injector)

    # No configuration after injection

    return app
Exemplo n.º 4
0
app = Flask(__name__)
app_api = Api(app=app,
              version="1.0",
              title="Sights Info App",
              description="Get Information About A Location.")


def getApp():
    return app


# Flask-SQLAlchemy: Initialize
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite3'
db.init_app(app)  # Bind SQLAlchemy to this Flask webapp
"""Define namespace"""
sights_name_space = app_api.namespace("sights",
                                      description='Get info about sights')

# Create the database tables and records inside a temporary test context
with app.test_request_context():
    load_db(db)


@app.route('/')
@app.route('/home')
def home():
    return render_template("home.html")

Exemplo n.º 5
0

@app.errorhandler(404)
def page_not_found(error):
    return render_template(templates['not_found'], error_code='404'), 404


@app.errorhandler(500)
def special_exception_handler(error):
    return render_template(templates['not_found'], error_code='500'), 500

login_manager.init_app(app)

DebugToolbarExtension(app)

db.init_app(app)

mail_handler = SMTPHandler(
    secure=(),
    mailhost=(SmtpConfig.SERVER, SmtpConfig.PORT),
    fromaddr=SmtpConfig.USER,
    toaddrs=Config.EMAIL,
    subject="%s GOT A SERIOUS PROBLEM" % Config.MAIN_TITLE.encode('utf-8'),
    credentials=(SmtpConfig.USER, SmtpConfig.PASSWORD)
)

define("port", default=8888, help="run on the given port", type=int)

if USED_CONF == 'config.ProductionConfig':
    env = False
else:
Exemplo n.º 6
0

@app.errorhandler(404)
def page_not_found(error):
    return render_template(templates['not_found'], error_code='404'), 404


@app.errorhandler(500)
def special_exception_handler(error):
    return render_template(templates['not_found'], error_code='500'), 500

login_manager.init_app(app)

DebugToolbarExtension(app)

db.init_app(app)

mail_handler = SMTPHandler(
    secure=(),
    mailhost=(SmtpConfig.SERVER, SmtpConfig.PORT),
    fromaddr=SmtpConfig.USER,
    toaddrs=Config.EMAIL,
    subject="%s GOT A SERIOUS PROBLEM" % Config.MAIN_TITLE.encode('utf-8'),
    credentials=(SmtpConfig.USER, SmtpConfig.PASSWORD)
)

define("port", default=8888, help="run on the given port", type=int)

if USED_CONF == 'config.ProductionConfig':
    env = False
else:
Exemplo n.º 7
0
        'handlers': ['wsgi']
    }
})

base_url = '/genosurf/'
api_url = base_url + 'api'
repo_static_url = base_url + 'repo_static'

my_app = Flask(__name__)

my_app.config['SQLALCHEMY_DATABASE_URI'] = get_db_uri()
my_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
my_app.config['SQLALCHEMY_POOL_SIZE'] = 1
my_app.config['SQLALCHEMY_MAX_OVERFLOW'] = 30

db.init_app(my_app)

simple_page = Blueprint('root_pages',
                        __name__,
                        static_folder='../vue-metadata/dist/static',
                        template_folder='../vue-metadata/dist')

graph_pages = Blueprint(
    'static',
    __name__,
    # static_url_path='/',
    static_folder='./repo_static/',
    # template_folder='../vue-metadata/dist'
)