diff --git a/Makefile b/Makefile index 15dd724..58cdb9f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ -all: ensure_env build serve +all: ensure_env clean build serve + +clean: + -@rm -rf src/rupload/__pycache__ ensure_env: -@python3 -m venv .venv diff --git a/README.md b/README.md index 0cb4672..8a1a39e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,30 @@ python3 -m venv .venv ``` ## Usage -``` -rupload.serve [host(127.0.0.1)] [port] [destination path for uploads] [max file size in bytes] -``` +`rupload.serve` [-h] + [--hostname HOSTNAME] + [--port PORT] + [--upload_folder UPLOAD_FOLDER] + [--upload_url UPLOAD_URL] + [--max_file_size MAX_FILE_SIZE] + +Start the file upload server. + +options: + -h, --help show this help message + and exit + --hostname HOSTNAME The hostname for the + server. + --port PORT The port to bind the + server to. + --upload_folder UPLOAD_FOLDER + Directory to store + uploaded files. + --upload_url UPLOAD_URL + HTTP(S) URL where the + server will serve the + uploaded files. + --max_file_size MAX_FILE_SIZE + Maximum file size in + bytes (default is + 50MB). diff --git a/src/rupload/__pycache__/app.cpython-312.pyc b/src/rupload/__pycache__/app.cpython-312.pyc index e8b797e..42295ff 100644 Binary files a/src/rupload/__pycache__/app.cpython-312.pyc and b/src/rupload/__pycache__/app.cpython-312.pyc differ diff --git a/src/rupload/__pycache__/cli.cpython-312.pyc b/src/rupload/__pycache__/cli.cpython-312.pyc index a87e8c1..0e5d83c 100644 Binary files a/src/rupload/__pycache__/cli.cpython-312.pyc and b/src/rupload/__pycache__/cli.cpython-312.pyc differ diff --git a/src/rupload/app.py b/src/rupload/app.py index 449deb1..e7101e7 100644 --- a/src/rupload/app.py +++ b/src/rupload/app.py @@ -5,15 +5,13 @@ import pathlib class Rupload(web.Application): - def __init__(self, upload_path, max_file_size): + def __init__(self, upload_url:str="/uploads/", upload_path:str="uploads", max_file_size:int=1024*1024*50): self.upload_path = upload_path self.max_file_size = max_file_size + self.upload_url = upload_url super().__init__() -UPLOAD_FOLDER = "uploads" -pathlib.Path(UPLOAD_FOLDER).mkdir(parents=True, exist_ok=True) - UPLOAD_PAGE = """ @@ -28,7 +26,7 @@ UPLOAD_PAGE = """ display: flex; justify-content: center; align-items: center; - height: 100vh; + margin: 0; } @@ -37,7 +35,6 @@ UPLOAD_PAGE = """ border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); padding: 20px; - text-align: center; width: 100%; max-width: 500px; } @@ -48,6 +45,13 @@ UPLOAD_PAGE = """ color: #333; } + h2 { + font-size: 20px; + margin-bottom: 20px; + color: #333; + clear: both; + } + form { display: flex; flex-direction: column; @@ -87,37 +91,104 @@ UPLOAD_PAGE = """ font-size: 14px; color: #777; } + + .thumbnail { + width: 100px; + height: 100px; + object-fit: cover; + margin: 10px; + float:left; + }