예제 #1
0
def main():
    """ Main fonction executed at the start of the application
        Call the update script to create and update the database
        if necessary. Then start the application main menu.
    """
    try:
        my_updater = updater.Updater()
        # if database doesn't exist, creates it
        print("Connexion à la base de données...")
        is_init = my_updater.initialize_database()
        # run update on database if argument -u has been specified
        # or if no update were made in the past month
        # or on the first execution
        args = parse_arguments()
        if args.update or is_time_to_update('config.json') or is_init:
            print("Mise à jour de la base de données...")
            my_updater.update()
            set_last_update_datetime('config.json')
        # run the application
        my_controller = co.Controller()
        my_controller.start()
    except sqlalchemy.exc.OperationalError as err:
        log.critical(
            "Impossible d'accéder à la base de données. "
            "Informations de connexion incorrectes. "
            "Error: %s", err)
예제 #2
0
# -*- coding: utf-8 -*-
from app import model
from app import controller
from app import utility
from app import config

from flask import Flask, request
from flask_cors import CORS
app = Flask(__name__)
CORS(app)

ctrl = controller.Controller()


@app.route("/")
def index():
    return "Hello, world!"


@app.route("/api/ml/summary", methods=['POST', 'GET'])
def summary():
    if request.method == 'POST':
        ctrl.summary_calc()
    return ctrl.summary_get()


@app.route("/api/ml/word", methods=['POST', 'GET'])
def word():
    if request.method == 'POST':
        ctrl.word_calc()
    return ctrl.word_get()
예제 #3
0
import os

from flask import request, jsonify, abort, Response

from app import app, auth
from app import controller

ctrl = controller.Controller(os.environ['YANDEX_TRANSLATE_API_KEY'])


@app.errorhandler(400)
def error400_view(exception):
    return {"id": "400", "message": "Bad request"}


@app.errorhandler(401)
def error401_view(exception):
    return {"id": "401", "message": "Unauthorized"}


@app.errorhandler(403)
def error403_view(exception):
    return {"id": "403", "message": "Forbidden"}


@app.errorhandler(404)
def error404_view(exception):
    return {"id": "404", "message": "Not found"}


@app.errorhandler(500)
예제 #4
0
 def setUp(self):
     sub = submarino.Submarino()
     self.controller = controller.Controller(sub)