fix: linter errors over app.py [no ci]

This commit is contained in:
Alec.Schmidt
2025-03-18 10:11:40 +01:00
parent 528da91ed4
commit 3d6abfa9bc

View File

@@ -18,12 +18,8 @@
from flask import request, Flask, url_for, render_template, redirect from flask import request, Flask, url_for, render_template, redirect
import operators import operators
import json import json
from dotenv import load_dotenv
import os import os
__author__ = 'Michael Mäder' __author__ = 'Michael Mäder'
__date__ = "2025-03-10" __date__ = "2025-03-10"
__version__ = "0.5" __version__ = "0.5"
@@ -40,7 +36,8 @@ A little web application that offers API calls for arithmetic operations
# creation of the Flask application # creation of the Flask application
app = Flask(__name__) app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY') # super secure key against CSRF attacks # super secure key against CSRF attacks
app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY')
# global variable containing the name of the login user # global variable containing the name of the login user
global_data = {'username': 'no_user'} global_data = {'username': 'no_user'}
@@ -51,18 +48,19 @@ global_data = {'username': 'no_user'}
def plus_one(): def plus_one():
try: try:
x = int(request.args.get('x', 1)) x = int(request.args.get('x', 1))
except: except ValueError:
return json.dumps({"error": "Type error"}) return json.dumps({"error": "Type error"})
return json.dumps({'x': operators.addition(x, 1)}) return json.dumps({'x': operators.addition(x, 1)})
# addition route, the parameters will be passed with 'x' and 'y' # addition route, the parameters will be passed with 'x' and 'y'
@app.route('/add') @app.route('/add')
def plus_y(): def plus_y():
try: try:
x = int(request.args.get('x', 1)) x = int(request.args.get('x', 1))
y = int(request.args.get('y', 1)) y = int(request.args.get('y', 1))
except: except ValueError:
return json.dumps({"error": "Type error"}) return json.dumps({"error": "Type error"})
return json.dumps({'result': operators.addition(x, y)}) return json.dumps({'result': operators.addition(x, y)})
@@ -73,7 +71,7 @@ def multiply_y():
try: try:
x = int(request.args.get('x', 1)) x = int(request.args.get('x', 1))
y = int(request.args.get('y', 1)) y = int(request.args.get('y', 1))
except: except ValueError:
return json.dumps({"error": "Type error"}) return json.dumps({"error": "Type error"})
return json.dumps({'result': operators.multiplication(x, y)}) return json.dumps({'result': operators.multiplication(x, y)})
@@ -84,7 +82,7 @@ def division_y():
try: try:
x = int(request.args.get('x', 1)) x = int(request.args.get('x', 1))
y = int(request.args.get('y', 1)) y = int(request.args.get('y', 1))
except: except ValueError:
return json.dumps({"error": "Type error"}) return json.dumps({"error": "Type error"})
return json.dumps({'result': operators.division(x, y)}) return json.dumps({'result': operators.division(x, y)})