예제 #1
0
파일: __init__.py 프로젝트: cgil/popx
def create_app():
    """Create and initialize the application."""
    app = Flask(__name__, static_folder='static')
    app.config['DEBUG'] = config.get('debug')

    @app.route('/favicon.ico')
    def favicon():
        return send_from_directory(os.path.join(app.root_path, 'static'),
                                   'favicon.ico',
                                   mimetype='image/vnd.microsoft.icon')

    @app.route('/')
    def home():
        return render_template('home.html',
                               is_production=not config.get('debug'),
                               **config.get('pages.home'))

    # Experience now - test.
    @app.route('/experiencenow')
    def experiencenow():
        return render_template('experiencenow.html',
                               is_production=not config.get('debug'),
                               **config.get('pages.experiencenow'))

    return app
예제 #2
0
from typing import Dict, Iterable

from pymongo.results import UpdateResult, DeleteResult, InsertManyResult
from pymongo.errors import OperationFailure
from pymongo.database import Database
from pymongo.cursor import Cursor
from pymongo import MongoClient
from bson import ObjectId

from utils.configuration import config

mongo_config = config.get("MONGO", {})
client = MongoClient(mongo_config.get("URI"))


def get_db(db_name: str = None) -> Database:
    if not db_name:
        return client[mongo_config.get("FINANCE_DB")]
    return client[db_name]


def create(collection_name: str, entity: Dict) -> bool:
    status = get_db()[collection_name].insert_one(entity)

    if not status.acknowledged:
        raise OperationFailure("Failed inserting doc")
    return status.acknowledged


def insert_bulk(collection_name: str, bulk: Iterable) -> InsertManyResult:
    return get_db()[collection_name].insert_many(bulk)
예제 #3
0
파일: __init__.py 프로젝트: cgil/popx
 def experiencenow():
     return render_template('experiencenow.html',
                            is_production=not config.get('debug'),
                            **config.get('pages.experiencenow'))
예제 #4
0
파일: __init__.py 프로젝트: cgil/popx
 def home():
     return render_template('home.html',
                            is_production=not config.get('debug'),
                            **config.get('pages.home'))