[+] modpacks_manager.py (pre-0.1-alpha)

Reorganized routes to prepare further modpack integration with pooled automatic updates
This commit is contained in:
Charles Le Maux 2024-09-25 18:31:57 +02:00
parent b4329614c1
commit 3c873089e8
2 changed files with 18 additions and 7 deletions

12
app.py
View File

@ -1,13 +1,12 @@
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, send_from_directory)
from flask import (Blueprint, Flask, Response, jsonify, request)
from flask_cors import CORS
from werkzeug import run_simple
from werkzeug.datastructures import ImmutableMultiDict, FileStorage
@ -16,6 +15,7 @@ from werkzeug.utils import secure_filename
import file_manager
import firebase_manager
import generic_executor
import modpacks_manager
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = 16 * 1000 * 1000 * 1000 #15.28MB~
@ -180,16 +180,14 @@ def upload():
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)
return modpacks_manager.get_modpacks()
@app.route('/modpacks/image/<path:filename>', methods=['GET'])
def serve_image(filename):
return send_from_directory('servers/modpacks', filename)
def get_modpack_image(filename):
return modpacks_manager.get_modpack_image(filename)
def api_cleanup() -> None:

13
modpacks_manager.py Normal file
View File

@ -0,0 +1,13 @@
import json
from flask import jsonify, send_from_directory
curseforge_api_key: str = "$2a$10$YRWGp5IY1imlN5HjbnGgJOyvyOtwLotUcut57cuW./PyzqTYMjWN6"
load_modpacks = lambda: json.load(open('servers/modpacks/a-metadata.txt'))
def get_modpacks():
modpacks = load_modpacks()
return jsonify(modpacks)
def get_modpack_image(filename):
return send_from_directory('servers/modpacks', filename)