Enhanced the Fiche-compatible HTTP server in PyFiche to accept file uploads using POST requests, providing a more standard method for sending files to the server. This update complements the existing TCP server, Recup, which facilitates downloading pastes via netcat.
Introduced the ability to handle file uploads via POST requests with necessary validations and directory management. Added security checks on both POST and GET methods which now verify client IP against allowlist and banlist. Implemented redirection after successful file upload, with a generated slug as the file identifier.
Refactored the 'do_POST' method, incorporating checks on request path and 'Content-Length' header, rejecting inappropriate requests swiftly. Created the upload functionality that reads the content and writes it to the designated data directory, using a new, unique slug for each file. Also added logging for requests, aiding in monitoring and debugging.
These enhancements create a more functional and secure system, laying the groundwork for future improvements and feature integrations.
Updated README to highlight PyFiche's lack of external dependencies, improving project clarity for potential users. Added a stub for the POST method in the Lines server signaling planned upload functionality with an informative 501 Not Implemented response to client requests. This sets the groundwork for future implementations of the file upload feature.
Introducing PyFiche, a pastebin service optimized for command-line usage, including a full suite of servers – a TCP-based 'Fiche' server, an HTTP 'Lines' server, and a 'Recup' server for file retrieval via netcat. The initial release features configuration via pyproject.toml, a comprehensive README, and the MIT license.
This robust solution allows for easy code snippet sharing, file uploads, and downloads without dependencies outside the Python standard library. Setup involves environment configuration and pip installation with the project's handle to git. The 'Fiche' server accepts specific command-line options for customizability, and banlists/allowlists manage server access control, with detailed logging available per user request. Users should note that HTTPS support requires a reverse proxy setup, as PyFiche itself does not handle SSL/TLS.
The '.gitignore' file ensures that local development directories, bytecode and sensitive files are excluded from the repository to maintain a clean working environment. This addition represents a significant milestone for the Private.coffee team in providing a self-contained pastebin service.