fix: linter errors over app.py [no ci]
This commit is contained in:
16
src/app.py
16
src/app.py
@@ -18,12 +18,8 @@
|
||||
from flask import request, Flask, url_for, render_template, redirect
|
||||
import operators
|
||||
import json
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
|
||||
|
||||
|
||||
__author__ = 'Michael Mäder'
|
||||
__date__ = "2025-03-10"
|
||||
__version__ = "0.5"
|
||||
@@ -40,7 +36,8 @@ A little web application that offers API calls for arithmetic operations
|
||||
# creation of the Flask application
|
||||
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_data = {'username': 'no_user'}
|
||||
@@ -51,18 +48,19 @@ global_data = {'username': 'no_user'}
|
||||
def plus_one():
|
||||
try:
|
||||
x = int(request.args.get('x', 1))
|
||||
except:
|
||||
except ValueError:
|
||||
return json.dumps({"error": "Type error"})
|
||||
|
||||
return json.dumps({'x': operators.addition(x, 1)})
|
||||
|
||||
|
||||
# addition route, the parameters will be passed with 'x' and 'y'
|
||||
@app.route('/add')
|
||||
def plus_y():
|
||||
try:
|
||||
x = int(request.args.get('x', 1))
|
||||
y = int(request.args.get('y', 1))
|
||||
except:
|
||||
except ValueError:
|
||||
return json.dumps({"error": "Type error"})
|
||||
return json.dumps({'result': operators.addition(x, y)})
|
||||
|
||||
@@ -73,7 +71,7 @@ def multiply_y():
|
||||
try:
|
||||
x = int(request.args.get('x', 1))
|
||||
y = int(request.args.get('y', 1))
|
||||
except:
|
||||
except ValueError:
|
||||
return json.dumps({"error": "Type error"})
|
||||
return json.dumps({'result': operators.multiplication(x, y)})
|
||||
|
||||
@@ -84,7 +82,7 @@ def division_y():
|
||||
try:
|
||||
x = int(request.args.get('x', 1))
|
||||
y = int(request.args.get('y', 1))
|
||||
except:
|
||||
except ValueError:
|
||||
return json.dumps({"error": "Type error"})
|
||||
return json.dumps({'result': operators.division(x, y)})
|
||||
|
||||
|
Reference in New Issue
Block a user