From 8147d5e01a427fc506d1337d73861951a9f7c96f Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Sat, 21 Sep 2024 12:46:48 +0200 Subject: [PATCH 1/2] [~] Simple type fix --- generic_executor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic_executor.py b/generic_executor.py index 71e5712..0316841 100644 --- a/generic_executor.py +++ b/generic_executor.py @@ -124,7 +124,7 @@ def fetch_players_status(user: UserRecord, name: str) -> tuple[HTTPStatus, Union def fetch_dir_content(user: UserRecord, name: str) -> tuple[HTTPStatus, Union[str, list]]: user_id: str = user.uid server_path: str = f"users/{user_id}/{name}/" - dirs: dict[str, [str, str]] = { + dirs: dict[str, list[str]] = { 'plugins': ['plugins', '.jar'], 'datapack' : ['world/datapacks', '.zip'], } From fca154b31ec90759d3eec7df79b8b50ab5122963 Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Sat, 21 Sep 2024 14:14:59 +0200 Subject: [PATCH 2/2] [+] New modpack metadata GET API routes. --- app.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 9feb7ef..38ce770 100644 --- a/app.py +++ b/app.py @@ -1,12 +1,13 @@ import argparse import http import inspect +import json import os from typing import Union from apscheduler.schedulers.background import BackgroundScheduler from firebase_admin.auth import UserNotFoundError, UserRecord -from flask import (Blueprint, Flask, Response, jsonify, request) +from flask import (Blueprint, Flask, Response, jsonify, request, send_from_directory) from flask_cors import CORS from werkzeug import run_simple from werkzeug.datastructures import ImmutableMultiDict, FileStorage @@ -178,6 +179,19 @@ def upload(): return generic_response_maker(http.HTTPStatus.OK, "Successfully uploaded files !") + +load_modpacks = lambda: json.load(open('servers/modpacks/a-metadata.txt')) +@app.route('/modpacks', methods=['GET']) +def get_modpacks(): + modpacks = load_modpacks() + return jsonify(modpacks) + + +@app.route('/modpacks/image/', methods=['GET']) +def serve_image(filename): + return send_from_directory('servers/modpacks', filename) + + def api_cleanup() -> None: firebase_manager.set_servers_not_running() return