mirror of
https://github.com/Radiquum/YAMPD.git
synced 2025-05-20 23:59:35 +05:00
feat: start pack view page
This commit is contained in:
parent
e109b5393a
commit
bb9ccaa6f1
6 changed files with 173 additions and 36 deletions
|
@ -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):
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue