diff --git a/run.py b/run.py index a3e4fcd..32af494 100755 --- a/run.py +++ b/run.py @@ -6,10 +6,5 @@ # Gui(theme='DarkGrey11', debug_mode=do_debug) -# Web App -from Web import create_app -app = create_app() -if __name__ == '__main__': - app.run(port=5000 ,debug=True) \ No newline at end of file diff --git a/run_web.py b/run_web.py new file mode 100644 index 0000000..06761d8 --- /dev/null +++ b/run_web.py @@ -0,0 +1,7 @@ +from web_app import create_app + + +app = create_app() + +if __name__ == '__main__': + app.run(port=7467 ,debug=False) \ No newline at end of file diff --git a/Web/__init__.py b/web_app/__init__.py similarity index 70% rename from Web/__init__.py rename to web_app/__init__.py index 7d2d82a..be7c432 100644 --- a/Web/__init__.py +++ b/web_app/__init__.py @@ -1,12 +1,12 @@ from flask import Flask -from Web.config import Config +from web_app.config import Config app = Flask(__name__) def create_app(config_class=Config): app.config.from_object(config_class) - from Web.main.routes import main + from web_app.main.routes import main app.register_blueprint(main) diff --git a/Web/config.py b/web_app/config.py similarity index 61% rename from Web/config.py rename to web_app/config.py index 0d6af55..095d79d 100644 --- a/Web/config.py +++ b/web_app/config.py @@ -1,3 +1,2 @@ class Config(): SECRET_KEY = '4542bae72a9fefada779b8c3fc68a826' - UPLOAD_FOLDER = '/path/to/the/uploads' \ No newline at end of file diff --git a/Web/main/__init__.py b/web_app/main/__init__.py similarity index 100% rename from Web/main/__init__.py rename to web_app/main/__init__.py diff --git a/Web/main/forms.py b/web_app/main/forms.py similarity index 100% rename from Web/main/forms.py rename to web_app/main/forms.py diff --git a/Web/main/routes.py b/web_app/main/routes.py similarity index 83% rename from Web/main/routes.py rename to web_app/main/routes.py index 10595f1..e746f63 100644 --- a/Web/main/routes.py +++ b/web_app/main/routes.py @@ -1,6 +1,6 @@ from flask.helpers import send_file from flask import render_template, abort, flash, Blueprint -from Web.main.forms import UploadJavaForm +from web_app.main.forms import UploadJavaForm from random import randint import shutil import secrets @@ -12,21 +12,19 @@ from interpreter.NassiShneidermann import NassiShneidermanDiagram, OB main = Blueprint('main', __name__) -def deleteFile(path): +def deleteFilesInFolder(path): file_list = os.listdir(path) for f in file_list: try: os.remove(path + '/' +f) - print("remove " + f) + # print("remove " + f) except: - print("fail to remove " + f) + try: + shutil.rmtree(path + '/' + f) + # print("remove " + f) + except: + logging.error("fail to remove " + f) -def deleteFolder(path): - try: - shutil.rmtree(path) - print("remove " + path) - except: - print("fail to remove " + path) def javaDatei(form_file): try: @@ -48,6 +46,7 @@ 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) ) @@ -74,10 +73,11 @@ def generator(): 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) - - deleteFolder(output_path) + deleteFilesInFolder(output_path) return send_file(zip_path + '.zip', as_attachment=True) + + return render_template('upload.html', title='Upload', legend='Upload', form=form ) diff --git a/Web/static/main.css b/web_app/static/main.css similarity index 100% rename from Web/static/main.css rename to web_app/static/main.css diff --git a/Web/templates/datenschutz.html b/web_app/templates/datenschutz.html similarity index 100% rename from Web/templates/datenschutz.html rename to web_app/templates/datenschutz.html diff --git a/Web/templates/layout.html b/web_app/templates/layout.html similarity index 100% rename from Web/templates/layout.html rename to web_app/templates/layout.html diff --git a/Web/templates/upload.html b/web_app/templates/upload.html similarity index 100% rename from Web/templates/upload.html rename to web_app/templates/upload.html