Initial Commit
This commit is contained in:
0
api/app/helpers/__init__.py
Normal file
0
api/app/helpers/__init__.py
Normal file
23
api/app/helpers/authentication.py
Normal file
23
api/app/helpers/authentication.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from flask_httpauth import HTTPBasicAuth
|
||||
|
||||
auth = HTTPBasicAuth()
|
||||
|
||||
|
||||
@auth.verify_password
|
||||
def verify_password(username_or_token, password):
|
||||
|
||||
if username_or_token == "user" and password == "passwd":
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def post_login_required(func):
|
||||
def post_decorator(*args, **kwargs):
|
||||
print("post_decorator ", func, *args, **kwargs)
|
||||
return auth.login_required(func)(*args, **kwargs)
|
||||
|
||||
if func.__name__ in ("post", "patch", "delete"):
|
||||
return post_decorator
|
||||
|
||||
return func
|
||||
3
api/app/helpers/database.py
Normal file
3
api/app/helpers/database.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
db = SQLAlchemy()
|
||||
2
api/app/helpers/math.py
Normal file
2
api/app/helpers/math.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def safe_division(n: int, d: int, r: int = 2):
|
||||
return round((n / d), r) if d else 0
|
||||
Reference in New Issue
Block a user