Example #1
0
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
Example #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)
Example #3
0
 def experiencenow():
     return render_template('experiencenow.html',
                            is_production=not config.get('debug'),
                            **config.get('pages.experiencenow'))
Example #4
0
 def home():
     return render_template('home.html',
                            is_production=not config.get('debug'),
                            **config.get('pages.home'))