Beispiel #1
0
def make_app(conf=None):
    """create and return an app object

    this function will create an application object and return it's instance. this
    could be used to create test client for testing or making deploy application
    and etc. though a user can just create an app and be fine with it, we are
    exposing this fucntion so the user is able to easily create applications
    without getting involved with importing different modules and functions from
    different files

    :param conf: name of the configuration to build the app with
    :return: application object
    """
    if not conf:
        conf = 'development'
    app = create_app(cm.get(conf))
    return app
Beispiel #2
0
def get_app_context(conf=None):
    """get an app context!

    we will receive the name of the application and then try to build out the
    applicaton and return it. the important thing with this function is that we
    will return the application context not the actual application object.
    this is usefull for modules and functions that need the application context
    to be able to do what they would need to do.

    the config is the name of the config class we want to use to create the app
    with.

    :param conf: name of the config class
    :return: a flask application context
    """
    if not conf:
        conf = 'development'
    try:
        app = create_app(cm.get(conf))
        with app.app_context() as ctx:
            yield ctx
    finally:
        pass
Beispiel #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# find . -name \*.pyc -delete
__author__ = 'AminHP'

# python imports
import os
from mongoengine.connection import disconnect

# project imports
from project.application import create_app
from project.config import DeploymentConfig

disconnect()
config_file = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                           "project/conf.py")
app = create_app(DeploymentConfig, "conf.py")

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080)
Beispiel #4
0
 def create_app(self):
     app = create_app()
     app.config['TESTING'] = True
     mixer.init_app(app)
     return app
Beispiel #5
0
from project.application import create_app

app = create_app()
Beispiel #6
0
    -

"""
import os
import sys

import click

from project.application import create_app
from project.config import CONFIG_MAPPER
from project.extensions import db

from project.apps.users_app.commands import auth_cli

deploy = os.environ.get('FLASK_ENV', 'development')
app = create_app(CONFIG_MAPPER.get(deploy))


def do_initdb(application=None):
    if not application:
        global app
    else:
        app = application
    try:
        with app.app_context():
            db.create_all()
            click.echo("db is initialized")
    except Exception as e:
        click.echo(str(e))

Beispiel #7
0
from flask import send_from_directory
import logging
import os
from project.application import create_app
from project.bl import init_resource_registry

init_resource_registry()
app = create_app()


@app.route('/media/<path:path>')
def get_file(path):
    return send_from_directory(app.config['UPLOAD_FOLDER'], path)


# noinspection PyUnusedLocal
@app.errorhandler(413)
def request_entity_too_large(error):
    return 'File Too Large', 413

if os.environ.get("WERKZEUG_RUN_MAIN") == "true":
    logging.info(app.url_map)
Beispiel #8
0
def app(database):
    app = create_app(Config)
    app.test_request_context().push()
    return app
Beispiel #9
0
from project.application import create_app

application = create_app()
Beispiel #10
0
import os

from project.application import create_app

conf = os.environ.get('conf', 'develop')
app = create_app(conf_name=conf)

if __name__ == '__main__':
    app.run(debug=True)