Skip to content

Commit

Permalink
added blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
agmes4 committed Sep 6, 2023
1 parent 8f6d24b commit 84ef0fb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions sipa/blueprints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from .news import bp_news
from .hooks import bp_hooks
from .register import bp_register
from .control import bp_control
34 changes: 34 additions & 0 deletions sipa/blueprints/control.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions sipa/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 84ef0fb

Please sign in to comment.