diff --git a/src/TranslationServer.py b/src/TranslationServer.py index e3cfda8..632d490 100644 --- a/src/TranslationServer.py +++ b/src/TranslationServer.py @@ -13,12 +13,12 @@ conn=None app=Flask(__name__, static_url_path="", static_folder="/var/www/") def check_run_mode(func): - @wraps(func) - def decorated_function(*args, **kwargs): - if RUN_MODE == "translate": - abort(404) - return func(*args, **kwargs) - return decorated_function + @wraps(func) + def decorated_function(*args, **kwargs): + if (RUN_MODE == "translate" or (RUN_MODE == "dict" and request.path == "/statistics")): + abort(404) + return func(*args, **kwargs) + return decorated_function def dict_mode(): global BUNDLES_PATH @@ -67,9 +67,10 @@ def check_database(): cursor.execute(create_signs_table) cursor.execute(create_platforms_table) cursor.execute(insert_platforms_default, ("ANDROID", 0)) - cursor.execute(insert_platforms_default, ("IOS", 0)) - cursor.execute(insert_platforms_default, ("WEBGL", 0)) - cursor.execute(insert_platforms_default, ("STANDALONE", 0)) + cursor.execute(insert_platforms_default, ("IOS", 0)) + cursor.execute(insert_platforms_default, ("WEBGL", 0)) + cursor.execute(insert_platforms_default, ("STANDALONE", 0)) + conn.commit() cursor.close() def insert_sign_db(sign_name, value, has): @@ -122,6 +123,7 @@ def translate(): return traduzir(text) @app.route("/statistics") +@check_run_mode def load_statistics_page(): page_path = os.path.join(app.static_folder, "statistics") php_output = check_output(["php", page_path]) @@ -137,7 +139,7 @@ def get_sign(): if __name__ == "__main__": parser = argparse.ArgumentParser(description='Translation server and signs download for VLibras.') parser.add_argument('--port', help='Port where the server will be available.', default=3000) - parser.add_argument("--mode", help="So that the server will work.", default="translate") - args = parser.parse_args() - init_mode(args) + parser.add_argument("--mode", help="So that the server will work.", default="translate") + args = parser.parse_args() + init_mode(args) app.run(host="0.0.0.0", port=int(args.port), threaded=True, debug=False) \ No newline at end of file -- libgit2 0.21.2