def create_app():
    app = Flask(__name__)
    CORS(app, resources={r"/*": {"origins": "*"}})
    DB.init()

    from app.words import words_bp
    from app.config import config_bp
    app.register_blueprint(words_bp, url_prefix='/')
    app.register_blueprint(config_bp, url_prefix='/')

    return app
Example #2
0
def getAnagramas(anagramaBase):
    anagramaList = []
    cursor = DB.findAll('words')
    for value in cursor:
        if sorted(value['item']) == sorted(anagramaBase):
            anagramaList.append(value['_id'])
    return anagramaList
Example #3
0
def getWords():
    wordList = []
    sorting = __getConfigSort()
    cursor = DB.findAll('words')
    if cursor.count() == 0:
        cursor = __initialInsert()
    for value in cursor:
        word = Words(value['_id'], value['item'])
        if len(sorting.sortItems) == cursor.count():
            sort_index = sorting.sortItems.index(word._id)
            wordList.insert(sort_index, word.json())
        else:
            wordList.append(word.json())
    return wordList
Example #4
0
from app.application import APP
from app.core.database import DB
from app.core.parser import get_categories_structure
from app import view

if __name__ == '__main__':
    if not DB.list_collection_names():
        get_categories_structure()
        DB.products.create_index('key', unique=True)
    APP.run()
def __update(config):
    if not DB.find_one("config", {"_id": config._id}):
        DB.insert(collection='config', data=config.json())
    DB.update("config", {"_id": config._id}, { "$set": { "sort_items": config.sortItems}})
def __findOne(_id):
    value = DB.find_one("config", {"_id": _id})
    if value:
        config = Config(value['_id'], value['sort_items'])
    return config
Example #7
0
def __initialInsert():
    DB.insert("words",
              Words(1, 'gato').json())
    DB.insert("words",
              Words(2, 'cosa').json())
    DB.insert("words",
              Words(3, 'nada').json())
    DB.insert("words",
              Words(4, 'aguila').json())
    DB.insert("words",
              Words(5, 'luciernaga').json())
    DB.insert("words",
              Words(6, 'cedro').json())
    DB.insert("words",
              Words(7, 'mampara').json())
    return DB.findAll('words')