Website4Share is a Rust-based web application for sharing files and pasteboard content.
- Rust and Cargo installed
- Docker installed (for containerization)
To run the application using Cargo, follow these steps:
-
Clone the repository:
git clone https://github.com/xz-dev/website4share.git cd website4share -
Set the required environment variables:
LISTEN_ADDR: The address and port the application will listen on (default:0.0.0.0:8080).TMPDIR: The directory for temporary files (default: system temporary directory).
Example:
export LISTEN_ADDR=0.0.0.0:8080 export TMPDIR=/path/to/tempdir
-
Run the application:
cargo run
To build and run the application using Docker, follow these steps:
-
Build the Docker image:
docker build -t website4share -f Containerfile . -
Run the Docker container:
docker run -d \ -p 8080:8080 \ -v /path/to/local/cache:/tmp/website4share \ -e LISTEN_ADDR=0.0.0.0:8080 \ --name website4share_container \ website4share
-d: Run the container in detached mode.-p 8080:8080: Map port 8080 on the host to port 8080 in the container.-v /path/to/local/cache:/tmp/website4share: Mount the local directory/path/to/local/cacheto/tmp/website4sharein the container. This ensures that the cache directory is persisted and not lost when the container is stopped or removed.-e LISTEN_ADDR=0.0.0.0:8080: Set theLISTEN_ADDRenvironment variable to0.0.0.0:8080to ensure the application listens on all network interfaces.--name website4share_container: Assign a name to the container for easier management.website4share: The name of the Docker image to run.
LISTEN_ADDR: The address and port the application will listen on. Default is0.0.0.0:8080.TMPDIR: The directory for temporary files. Default is the system temporary directory + website4share.
src/: Source code of the application.Cargo.toml: Cargo configuration file.Containerfile: Dockerfile for building the Docker image.static/: Static files served by the application.
- Just a website
- Multi share thread
- Upload resume
- Terminal API (curl friendly)
All upload endpoints return plain text URLs by default. Add Accept: application/json header for JSON response.
curl -s -X POST http://localhost:8080/api/v1/new/myspace# Pipe stdin
echo "hello world" | curl -s -X POST --data-binary @- http://localhost:8080/api/v1/paste/myspace
# From wl-clipboard
wl-paste | curl -s -X POST --data-binary @- http://localhost:8080/api/v1/paste/myspace
# From X11 clipboard
xclip -selection clipboard -o | curl -s -X POST --data-binary @- http://localhost:8080/api/v1/paste/myspace
# Returns: /api/v1/paste/myspace/<id>curl http://localhost:8080/api/v1/paste/myspace/<id>
# Copy to clipboard
curl http://localhost:8080/api/v1/paste/myspace/<id> | wl-copycurl --upload-file photo.jpg http://localhost:8080/api/v1/file/myspace/photo.jpg
# Returns: /files/myspace/files/photo.jpgcurl -O http://localhost:8080/files/myspace/files/photo.jpg# List all spaces
curl http://localhost:8080/api/v1/list
# ["myspace", "other"]
# List pasteboard & files in a space (JSON, with download URLs)
curl http://localhost:8080/api/v1/list/myspace
# {
# "pasteboard": [{"id":"..", "url":"/api/v1/paste/myspace/..", "timestamp":.., "size":..}],
# "files": [{"name":"..", "url":"/files/myspace/files/..", "timestamp":.., "size":..}]
# }echo "hello" | curl -s -X POST -H "Accept: application/json" --data-binary @- http://localhost:8080/api/v1/paste/myspace
# {"url":"/api/v1/paste/myspace/...","id":"..."}Add to your .bashrc / .zshrc:
export W4S_HOST="http://localhost:8080"
w4s-new() { curl -s -o /dev/null -w "%{http_code}" -X POST "$W4S_HOST/api/v1/new/$1"; }
w4s-paste() { curl -s -X POST --data-binary @- "$W4S_HOST/api/v1/paste/$1"; }
w4s-get() { curl -s "$W4S_HOST$1"; }
w4s-up() { curl --upload-file "$2" "$W4S_HOST/api/v1/file/$1/$(basename $2)"; }
w4s-ls() { curl -s "$W4S_HOST/api/v1/list${1:+/$1}"; }
# Usage:
w4s-new myspace # create space
echo "hello" | w4s-paste myspace # paste text
w4s-get /api/v1/paste/myspace/<id> # get text
w4s-up myspace photo.jpg # upload file
w4s-ls # list all spaces
w4s-ls myspace # list space contents| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/new/{pname} |
Create a space |
| POST | /api/v1/paste/{pname} |
Upload text (raw body), returns URL |
| GET | /api/v1/paste/{pname}/{id} |
Download text |
| PUT | /api/v1/file/{pname}/{name} |
Upload file (raw body), returns URL |
| GET | /api/v1/list |
List all spaces (JSON array) |
| GET | /api/v1/list/{pname} |
List space contents (JSON with URLs) |
All Terminal API endpoints return 400 with invalid pname or invalid path if the path segment contains .., /, or \.


