コード例 #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
コード例 #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
コード例 #3
0
ファイル: deploy.py プロジェクト: salarnasiri/ijust_server
#!/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)
コード例 #4
0
ファイル: utils.py プロジェクト: nlyubchich/ask_linguist
 def create_app(self):
     app = create_app()
     app.config['TESTING'] = True
     mixer.init_app(app)
     return app
コード例 #5
0
ファイル: __init__.py プロジェクト: Ne1c/ProjectS_Server
from project.application import create_app

app = create_app()
コード例 #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))

コード例 #7
0
ファイル: __init__.py プロジェクト: nlyubchich/Meowth
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)
コード例 #8
0
ファイル: conftest.py プロジェクト: odiroot/mofanhu
def app(database):
    app = create_app(Config)
    app.test_request_context().push()
    return app
コード例 #9
0
ファイル: wsgi.py プロジェクト: odiroot/mofanhu
from project.application import create_app

application = create_app()
コード例 #10
0
ファイル: app.py プロジェクト: senaps/stms
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)