diff --git a/api_sender.html b/api_sender.html
index 05ce61b..8b028cb 100644
--- a/api_sender.html
+++ b/api_sender.html
@@ -12,7 +12,7 @@
Port:
Name:
Version:
- Framework:
+ Framework:
@@ -20,6 +20,8 @@
+
+
Update Property
@@ -64,6 +66,9 @@ document.addEventListener('DOMContentLoaded', () => {
case 'FetchServers':
data = {token};
break;
+ case 'FetchLogs':
+ data = {token, name};
+ break;
case 'AccountCreate':
data = {email, port, token};
break;
diff --git a/app.py b/app.py
index 8cc2587..99d5ebd 100644
--- a/app.py
+++ b/app.py
@@ -81,6 +81,7 @@ def parse_and_validate_request(parameters: list[str]) -> Union[list[str], None]:
route_handlers = {
'SetSubdomain': generic_executor.set_subdomain,
'FetchServers': generic_executor.fetch_servers,
+ 'FetchLogs': generic_executor.fetch_logs,
'AccountCreate': generic_executor.account_create,
'ServerCreate': generic_executor.server_create,
'ServerDelete': generic_executor.server_delete,
diff --git a/generic_executor.py b/generic_executor.py
index 12ac2f4..6f47f46 100644
--- a/generic_executor.py
+++ b/generic_executor.py
@@ -68,7 +68,16 @@ def fetch_servers(user: UserRecord) -> tuple[HTTPStatus, Union[str, list]]:
def fetch_logs(user: UserRecord, name: str) -> tuple[HTTPStatus, Union[str, None]]:
- pass
+ user_id: str = user.uid
+ lines_to_read: int = 200
+ log_file = f"users/{user_id}/{name}/logs/latest.log"
+ try:
+ with open(log_file, "r") as f:
+ logs = f.readlines()[-lines_to_read:]
+ text_logs = f.read()
+ return HTTPStatus.OK, str(logs)
+ except FileNotFoundError:
+ return HTTPStatus.NOT_FOUND, "Log file not found."
def account_create(user: UserRecord) -> tuple[HTTPStatus, Union[str, None]]: