feat: add annotations about functionalities of some endpoints
This commit is contained in:
@@ -29,7 +29,7 @@ def safeTraverse(obj: dict, path: list, default=None):
|
||||
finally:
|
||||
return result
|
||||
|
||||
def getCommit():
|
||||
def getCommit() -> str | None:
|
||||
try:
|
||||
return Repo(search_parent_directories=True).head.object.hexsha
|
||||
except Exception as e:
|
||||
@@ -65,7 +65,7 @@ def ensureRandomlyGeneratedPassword():
|
||||
print(f"{colors.WARNING}WARNING{colors.ENDC}: Default config populated with one-time, insecure pseudorandom API key: {colors.OKCYAN}{randomly_generated_passcode}{colors.ENDC}.\n"
|
||||
f" The API key is not the Flask debugger PIN. You need to provide a config file for persistence!{colors.ENDL}")
|
||||
|
||||
def getConfig(configfile):
|
||||
def getConfig(configfile: str) -> dict:
|
||||
global randomly_generated_passcode
|
||||
|
||||
if not os.path.exists(configfile):
|
||||
@@ -82,15 +82,26 @@ def getConfig(configfile):
|
||||
else:
|
||||
return toml.load(configfile)
|
||||
|
||||
def setupDb(app, config):
|
||||
def setupDb(app, config) -> lewy_db.baza:
|
||||
global db
|
||||
db = lewy_db.baza(app, config)
|
||||
return db
|
||||
|
||||
def getDb():
|
||||
def getDb() -> lewy_db.baza:
|
||||
"""
|
||||
Akcesor dla wrappera bazy danych wspólnego dla całego projektu
|
||||
(klasy baza z lewy_db)
|
||||
"""
|
||||
return db
|
||||
|
||||
def setConfig(configfile):
|
||||
"""
|
||||
Zapewnia, że konfiguracja nie jest pusta,
|
||||
nawet, gdy sam plik jest pusty.
|
||||
|
||||
:param configfile: Ścieżka do pliku
|
||||
:type configfile: str
|
||||
"""
|
||||
global config
|
||||
config = getConfig(configfile)
|
||||
|
||||
@@ -100,6 +111,11 @@ def setConfig(configfile):
|
||||
|
||||
|
||||
def getHeaders():
|
||||
"""
|
||||
Zwraca hardkodowane nagłówki do scrapowania, bądź te,
|
||||
z config.toml (o ile użytkownik jakieś podał).
|
||||
"""
|
||||
|
||||
# NOTE: use ESR user-agent
|
||||
# user_agent = 'Mozilla/5.0 (Windows NT 10.0; rv:130.0) Gecko/20100101 Firefox/130.0'
|
||||
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0'
|
||||
@@ -110,10 +126,18 @@ def getHeaders():
|
||||
return user_agent
|
||||
|
||||
def getUptime():
|
||||
"""
|
||||
Zwraca informację o czasie działania serwera.
|
||||
"""
|
||||
return int(time.time()) - starttime
|
||||
|
||||
def extractIpAndPortFromPublicUrl() -> tuple:
|
||||
|
||||
"""
|
||||
Pobiera dane z konfiguracji i zwraca
|
||||
krotkę: adres IP i port.
|
||||
"""
|
||||
|
||||
ip, port = "127.0.0.1", "5000"
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user