mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
Merge pull request #35 from hubHarmony/plugin-management-system
Plugin management system
This commit is contained in:
commit
a0c908ad25
16
app.py
16
app.py
@ -1,12 +1,13 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import http
|
import http
|
||||||
import inspect
|
import inspect
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
from firebase_admin.auth import UserNotFoundError, UserRecord
|
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 flask_cors import CORS
|
||||||
from werkzeug import run_simple
|
from werkzeug import run_simple
|
||||||
from werkzeug.datastructures import ImmutableMultiDict, FileStorage
|
from werkzeug.datastructures import ImmutableMultiDict, FileStorage
|
||||||
@ -178,6 +179,19 @@ def upload():
|
|||||||
return generic_response_maker(http.HTTPStatus.OK, "Successfully uploaded files !")
|
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:
|
def api_cleanup() -> None:
|
||||||
firebase_manager.set_servers_not_running()
|
firebase_manager.set_servers_not_running()
|
||||||
return
|
return
|
||||||
|
@ -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]]:
|
def fetch_dir_content(user: UserRecord, name: str) -> tuple[HTTPStatus, Union[str, list]]:
|
||||||
user_id: str = user.uid
|
user_id: str = user.uid
|
||||||
server_path: str = f"users/{user_id}/{name}/"
|
server_path: str = f"users/{user_id}/{name}/"
|
||||||
dirs: dict[str, [str, str]] = {
|
dirs: dict[str, list[str]] = {
|
||||||
'plugins': ['plugins', '.jar'],
|
'plugins': ['plugins', '.jar'],
|
||||||
'datapack' : ['world/datapacks', '.zip'],
|
'datapack' : ['world/datapacks', '.zip'],
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user