diff --git a/src/cli.py b/src/carouselcmd.py similarity index 100% rename from src/cli.py rename to src/carouselcmd.py diff --git a/src/gui.py b/src/carouselgui.py similarity index 100% rename from src/gui.py rename to src/carouselgui.py diff --git a/src/cgi/carousel.cgi b/src/cgi/carousel.cgi new file mode 100755 index 0000000..c17615e --- /dev/null +++ b/src/cgi/carousel.cgi @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" + +if [[ "$QUERY_STRING" == "source" ]]; then + echo "Content-Type: text/plain" + echo + sed 's/&/\&/g; s/\</g; s/>/\>/g' "$0" + exit 0 +fi + +exec "$SCRIPT_DIR/../../.venv/bin/python" "$SCRIPT_DIR/script.py" diff --git a/src/cgi/carousel.py b/src/cgi/carousel.py deleted file mode 100644 index c1aa166..0000000 --- a/src/cgi/carousel.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env -S uv run python - -import os -from dotenv import load_dotenv - -load_dotenv() -logdir = os.getenv("CAROUSEL_LOGDIR") - -import cgi, cgitb - -cgitb.enable(display=0, logdir=logdir) - -form = cgi.FieldStorage() - -from ..carousel import * - -print("Content-Type: text/html") -print() - -print("
File extension is not valid. Use CSV (.csv) or Excel (.xlsx, .xls).
+ + """ + + # TODO: unpack df appropriately + if df is not None: + # Normalize + df = df.with_columns( + [ + pl.col(c) + .cast(pl.Utf8) + .str.strip_chars() + .cast(pl.Int64, strict=False) + .fill_null(0) + for c in df.columns + ] + ) + + match = match_from_prefs(df) # Solve! + + message = f""" +DataFrame was empty.
+ + """ + + except Exception as e: + message = f""" +Internal Error Encountered: {e} +
+ """ + traceback.print_exc() + + else: + message = """ +Filename or File Data not found/valid in form submission.
+ + """ + +else: + message = """ +No file field found in the form.
+ + """ + +print(""" + + + + + +