[+] New modpack metadata GET API routes.

This commit is contained in:
Charles Le Maux 2024-09-21 14:14:59 +02:00
parent 8147d5e01a
commit fca154b31e

16
app.py
View File

@ -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/<path:filename>', methods=['GET'])
def serve_image(filename):
return send_from_directory('servers/modpacks', filename)
def api_cleanup() -> None:
firebase_manager.set_servers_not_running()
return