mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] New 'FetchLogs' API call
[+] New 'FetchLogs' API call
This commit is contained in:
commit
66d6483f46
@ -12,7 +12,7 @@
|
||||
Port: <label for="accountPort"></label><input type="number" id="accountPort"><br>
|
||||
Name: <label for="serverName"></label><input type="text" id="serverName"><br>
|
||||
Version: <label for="serverVersion"></label><input type="text" id="serverVersion"><br>
|
||||
Framework: <label for="serverVersion"></label><input type="text" id="serverFramework"><br>
|
||||
Framework: <label for="serverFramework"></label><input type="text" id="serverFramework"><br>
|
||||
<button type="button" class="actionButton" data-action="AccountCreate">Create Account</button>
|
||||
<button type="button" class="actionButton" data-action="AccountDelete">Delete Account</button>
|
||||
<button type="button" class="actionButton" data-action="ServerCreate">Create Server</button>
|
||||
@ -20,6 +20,8 @@
|
||||
<button type="button" class="actionButton" data-action="ServerRun">Start Server</button>
|
||||
<button type="button" class="actionButton" data-action="ServerStop">Stop Server</button>
|
||||
<button type="button" class="actionButton" data-action="FetchServers">Fetch Servers</button>
|
||||
<button type="button" class="actionButton" data-action="FetchLogs">Fetch Logs</button>
|
||||
|
||||
</form>
|
||||
|
||||
<h2>Update Property</h2>
|
||||
@ -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;
|
||||
|
1
app.py
1
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,
|
||||
|
@ -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]]:
|
||||
|
Loading…
Reference in New Issue
Block a user