diff --git a/pyproject.toml b/pyproject.toml index f740763..d6ea504 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "support_formatter" -version = "0.1.0-a.2" +version = "0.1.0" requires-python = ">= 3.10" authors = [{name = "Firq", email = "firelp42@gmail.com"}] maintainers = [{name = "Firq", email = "firelp42@gmail.com"}] diff --git a/support_formatter/pages/error.html b/support_formatter/pages/error.html deleted file mode 100644 index ca5dcdb..0000000 --- a/support_formatter/pages/error.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - Support File Converter - Error - - - -

Error

- - - \ No newline at end of file diff --git a/support_formatter/pages/index.html b/support_formatter/pages/index.html deleted file mode 100644 index 1feca42..0000000 --- a/support_formatter/pages/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Support File Converter - - - -

Convert to Nerone-compatible data

-
- - -
- - -
-
- -
- -
-
- -
- -
-
- -
- - - \ No newline at end of file diff --git a/support_formatter/routes/upload.py b/support_formatter/routes/upload.py index 42e3b88..ab72d3d 100644 --- a/support_formatter/routes/upload.py +++ b/support_formatter/routes/upload.py @@ -1,7 +1,6 @@ import os import pathlib from typing import List -from flask import send_from_directory import marshmallow as ma from flask_smorest.fields import Upload from werkzeug.datastructures import FileStorage @@ -26,7 +25,7 @@ class MultipartFileSchema(ma.Schema): servantdata = Upload() cedata = Upload() -@blp.route("/", methods=["POST"]) +@blp.route("/upload", methods=["POST"]) @blp.arguments(MultipartFormSchema, location="form") @blp.arguments(MultipartFileSchema, location="files") @blp.response(200) @@ -39,7 +38,7 @@ def upload_file(form: dict[str, str], files: dict[str, FileStorage]): for name, file in files.items(): if name not in ("servantdata", "cedata"): - return send_from_directory(APISettings.PAGES_DIRECTORY, "error.html") + return { "status": 406, "message": "Invalid form sent" }, 406 filepath = APISettings.FILE_SAVE_DIRECTORY / f"{uuid.uuid4()}.csv" file.save(filepath) @@ -51,7 +50,7 @@ def upload_file(form: dict[str, str], files: dict[str, FileStorage]): filepaths.append(filepath) if len(filepaths) == 0: - return send_from_directory(APISettings.PAGES_DIRECTORY, "error.html") + return { "status": 406, "message": "No files provided" }, 406 try: for f in filepaths: @@ -61,10 +60,6 @@ def upload_file(form: dict[str, str], files: dict[str, FileStorage]): except FileTypeInvalidError: for f in filepaths: f.unlink() - return send_from_directory(APISettings.PAGES_DIRECTORY, "error.html") + return { "status": 500, "message": "Error whilst parsing uploaded file - please contact Firq on Fate/Sacc Order" }, 406 return returndata - -@blp.route("/", methods=["GET"]) -def file_dialog(): - return send_from_directory(APISettings.PAGES_DIRECTORY, "index.html")