diff --git a/run.py b/run.py index 32af494..95a5aa3 100755 --- a/run.py +++ b/run.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -# from gui.gui import Gui -# import sys +from gui.gui import Gui +import sys -# do_debug = "--debug" in sys.argv +do_debug = "--debug" in sys.argv -# Gui(theme='DarkGrey11', debug_mode=do_debug) +Gui(theme='DarkGrey11', debug_mode=do_debug) diff --git a/tmp/output.zip b/tmp/output.zip new file mode 100644 index 0000000..c669cca Binary files /dev/null and b/tmp/output.zip differ diff --git a/web_app/__init__.py b/web_app/__init__.py index be7c432..fe7fbaf 100644 --- a/web_app/__init__.py +++ b/web_app/__init__.py @@ -7,7 +7,9 @@ def create_app(config_class=Config): app.config.from_object(config_class) from web_app.main.routes import main - + from web_app.errors.handlers import errors + app.register_blueprint(main) + app.register_blueprint(errors) return app \ No newline at end of file diff --git a/web_app/errors/__init__.py b/web_app/errors/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/web_app/errors/handlers.py b/web_app/errors/handlers.py new file mode 100644 index 0000000..bdc5bf8 --- /dev/null +++ b/web_app/errors/handlers.py @@ -0,0 +1,23 @@ +from flask import Blueprint, render_template + +errors = Blueprint('errors', __name__) + +@errors.app_errorhandler(404) +def error_404(error): + return render_template('errors/404.html'), 404 + +@errors.app_errorhandler(403) +def error_403(error): + return render_template('errors/403.html'), 403 + +@errors.app_errorhandler(500) +def error_500(error): + return render_template('errors/500.html'), 500 + +@errors.app_errorhandler(418) +def error_600(error): + return render_template('errors/418.html'), 418 + +@errors.app_errorhandler(512) +def error_600(error): + return render_template('errors/512.html'), 512 \ No newline at end of file diff --git a/web_app/main/routes.py b/web_app/main/routes.py index e746f63..8bfffeb 100644 --- a/web_app/main/routes.py +++ b/web_app/main/routes.py @@ -46,21 +46,24 @@ def generator(): if form.validate_on_submit(): if form.java.data: - deleteFilesInFolder(os.path.join(os.path.abspath(os.path.join('Web', os.pardir)), f'../tmp/output/')) input_path = javaDatei(form.java.data) output_path = os.path.join(os.path.abspath(os.path.join('Web', os.pardir)), './tmp/input') outputname = str(randint(0, 100) ) + output_path_zip = os.path.join(os.path.abspath(os.path.join('Web', os.pardir)), f'./tmp/output/{outputname}') + remove_tags = None comments = None behaviour = OB.RANDOM_NAME types = None + + deleteFilesInFolder(str(os.path.join(os.path.abspath(os.path.join('Web', os.pardir)), './tmp/output/'))) NSD = NassiShneidermanDiagram(True) output_directory = output_path + '/' + outputname - + try: - if not os.path.exists(output_directory): + if not os.path.exists(output_directory): os.makedirs(output_directory) except OSError: logging.error('Error: Creating directory. ' + output_directory) @@ -71,11 +74,10 @@ def generator(): NSD.load_from_file(input_path, custom_tags) NSD.convert_to_image(output_directory, on_conflict=behaviour) - zip_path = os.path.join(os.path.abspath(os.path.join('Web', os.pardir)), f'../tmp/output/{outputname}') - shutil.make_archive(zip_path, 'zip', output_directory) + shutil.make_archive(output_path_zip, 'zip', output_directory) deleteFilesInFolder(output_path) - return send_file(zip_path + '.zip', as_attachment=True) + return send_file(output_path_zip + '.zip', as_attachment=True) diff --git a/web_app/templates/errors/403.html b/web_app/templates/errors/403.html new file mode 100644 index 0000000..b87049e --- /dev/null +++ b/web_app/templates/errors/403.html @@ -0,0 +1,7 @@ +{% extends 'layout.html' %} +{% block content %} +
Hier gibt es nichts zusehen, suchen Sie an einem anderen Ort!
+Versuch es in Zukunft nochmal oder frag Ole, wie lange er für diese Funktion noch brauch. Wenn du einen Verbesserungsvorschlag hast, melde dich bei Ole.
+Versuch es in naher Zukunft nochmal.
+Hier gibt es nichts zusehen!
+