diff --git a/sipa/blueprints/__init__.py b/sipa/blueprints/__init__.py index a1576c12..4b86f5b6 100644 --- a/sipa/blueprints/__init__.py +++ b/sipa/blueprints/__init__.py @@ -6,3 +6,4 @@ from .news import bp_news from .hooks import bp_hooks from .register import bp_register +from .control import bp_control diff --git a/sipa/blueprints/control.py b/sipa/blueprints/control.py new file mode 100644 index 00000000..9a198b34 --- /dev/null +++ b/sipa/blueprints/control.py @@ -0,0 +1,34 @@ + +from collections import OrderedDict +import logging +from datetime import datetime + +from babel.numbers import format_currency +from flask import Blueprint, render_template, url_for, redirect, flash, abort, request, current_app +from flask_babel import format_date, gettext +from flask_login import current_user, login_required +from flask_wtf import FlaskForm +from markupsafe import Markup + +bp_control = Blueprint('control', __name__, url_prefix='/control') +@bp_control.route("/port", methods=['GET', 'POST']) +def check_port(): + """ + returns json with all the port forwardings + """ + if not request.form.get("port"): + return 'port nicht in Textfeld' + if not request.form["port"].isnumeric(): + return gettext('der Port muss eine Nummer sein') + if int(request.form["port"]) < 1: + return gettext('der Port muss größer als 0 sein') + if int(request.form["port"]) > 65535: + return gettext('der Port muss kleiner als 65536 sein') + return "" + +@bp_control.route("/ip", methods=['GET', 'POST']) +def checks_ip_address(): + """ + checks rather the given ip address is valid + """ + pass \ No newline at end of file diff --git a/sipa/initialization.py b/sipa/initialization.py index fdc259f0..d9795ef3 100644 --- a/sipa/initialization.py +++ b/sipa/initialization.py @@ -12,6 +12,7 @@ from sipa.babel import possible_locales, save_user_locale_setting, select_locale from sipa.base import IntegerConverter, login_manager +from sipa.blueprints import bp_control from sipa.blueprints.usersuite import get_attribute_endpoint from sipa.defaults import DEFAULT_CONFIG from sipa.flatpages import CategorizedFlatPages @@ -69,6 +70,7 @@ def init_app(app, **kwargs): app.register_blueprint(bp_news) app.register_blueprint(bp_hooks) app.register_blueprint(bp_register) + app.register_blueprint(bp_control) logger.debug('Registering Jinja globals') form_label_width = 3