feat: start pack view page

This commit is contained in:
Kentai Radiquum 2025-05-05 23:03:57 +05:00
parent e109b5393a
commit bb9ccaa6f1
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
6 changed files with 173 additions and 36 deletions

View file

@ -1,12 +1,25 @@
import os
import re
from . import apiPack
from flask import request, jsonify, send_file, redirect, url_for
from flask import request, jsonify, send_file, redirect, url_for, abort
from config import PACKS_FOLDER, IMG_ALLOWED_MIME
from PIL import Image
from io import BytesIO
import base64
import json
@apiPack.route("/<id>", methods=["GET"])
def getPack(id):
if not os.path.exists(f"{PACKS_FOLDER}/{id}/packfile.json"):
return jsonify({"status": "error", "message": "not found"}), 404
pack = {}
with open(f"{PACKS_FOLDER}/{id}/packfile.json") as fp:
pack = json.load(fp)
pack["_id"] = id
fp.close()
return jsonify(pack)
@apiPack.route("/<id>/image", methods=["GET"])
def getPackImage(id):

View file

@ -3,6 +3,7 @@ from . import apiPacks
from flask import request, jsonify
from config import PACKS_FOLDER
import json
import shutil
@apiPacks.route("/all", methods=["GET"])
@ -59,3 +60,14 @@ def createPack():
"id": title,
}
)
@apiPacks.route("/<id>/delete", methods=["GET"])
def deletePack(id):
shutil.rmtree(f"{PACKS_FOLDER}/{id}")
return jsonify(
{
"status": "ok",
"message": f"pack deleted",
}
)