+ add error pages
This commit is contained in:
@@ -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
|
||||
0
web_app/errors/__init__.py
Normal file
0
web_app/errors/__init__.py
Normal file
23
web_app/errors/handlers.py
Normal file
23
web_app/errors/handlers.py
Normal file
@@ -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
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
7
web_app/templates/errors/403.html
Normal file
7
web_app/templates/errors/403.html
Normal file
@@ -0,0 +1,7 @@
|
||||
{% extends 'layout.html' %}
|
||||
{% block content %}
|
||||
<div class="content-section">
|
||||
<h1>Fehler 403</h1>
|
||||
<h5>Oops. Das dürfen Sie nicht!</h5>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
8
web_app/templates/errors/404.html
Normal file
8
web_app/templates/errors/404.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends 'layout.html' %}
|
||||
{% block content %}
|
||||
<div class="content-section">
|
||||
<h1>Fehler 404</h1>
|
||||
<h5>Oops. Diese Seite existiert nicht</h5>
|
||||
<p>Hier gibt es nichts zusehen, suchen Sie an einem anderen Ort!</p>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
8
web_app/templates/errors/418.html
Normal file
8
web_app/templates/errors/418.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends 'layout.html' %}
|
||||
{% block content %}
|
||||
<div class="content-section">
|
||||
<h1>Funktion nicht fertig.</h1>
|
||||
<h5>Oops. Ole hat diese Funktion der Webseite noch nicht fertig gestellt.</h5>
|
||||
<p>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.</p>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
8
web_app/templates/errors/500.html
Normal file
8
web_app/templates/errors/500.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends 'layout.html' %}
|
||||
{% block content %}
|
||||
<div class="content-section">
|
||||
<h1>Fehler 500</h1>
|
||||
<h5>Oops. Ole oder Kons haben was falsch gemacht</h5>
|
||||
<p>Versuch es in naher Zukunft nochmal.</p>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
8
web_app/templates/errors/512.html
Normal file
8
web_app/templates/errors/512.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends 'layout.html' %}
|
||||
{% block content %}
|
||||
<div class="content-section">
|
||||
<h1>Die Seite wird gerade überarbeitet</h1>
|
||||
<h5>Gedult!</h5>
|
||||
<p>Hier gibt es nichts zusehen!</p>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
@@ -27,7 +27,7 @@
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||
<div class="navbar-nav mr-auto">
|
||||
<a class="nav-item nav-link" href="nassi.ole-siepmann.de">Home</a>
|
||||
<a class="nav-item nav-link" href="http://nassi.ole-siepmann.de">Home</a>
|
||||
<a class="nav-item nav-link" href="https://ole-siepmann.de/startseite/datenschutzerklaerung/">Datenschutz</a>
|
||||
</div>
|
||||
<!-- Navbar Right Side -->
|
||||
|
||||
Reference in New Issue
Block a user