https://github.com/gztimewalker/berry-pasty
Just a pastebin and url shortener. Multi arch with only ~4MB image size.
https://github.com/gztimewalker/berry-pasty
Last synced: about 1 year ago
JSON representation
Just a pastebin and url shortener. Multi arch with only ~4MB image size.
- Host: GitHub
- URL: https://github.com/gztimewalker/berry-pasty
- Owner: GZTimeWalker
- License: mit
- Created: 2024-05-31T22:41:32.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-01T15:36:51.000Z (over 1 year ago)
- Last Synced: 2025-04-21T10:17:57.905Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 85.9 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Berry Pasty
A simple **pure Rust** pastebin and url shortener, inspired by [pasty](https://github.com/darkyzhou/pasty).
> [!TIP]
>
> **The image size is only 3.9MiB (1.77MiB compressed), currently support x86_64, aarch64.**
>
> Theoretically, it can be compiled to any Rust-supported architecture and run as a single binary.
## Usage
### Access
- **Index**
You can set the index text or link in the configuration file, if the index link is specified, it will redirect to the link directly.
- **Access a paste**
To access a paste, you can just visit the link.
```bash
curl http://localhost:8080/
```
### Update
To update (or add) a paste, you can send a POST request to the server with the content in the body, the server will return the link to the paste.
- **Update a text paste**
To update (or add) a text paste, you can send a POST request to the server with the content in the body, the server will return the link to the paste.
```bash
curl --data "Hello, World!" http://localhost:8080/access=
```
- **Update a redirect link**
To update (or add) a redirect link, you should specify the type as `link` and the link in the body.
```bash
curl --data "https://example.com" http://localhost:8080/access=&type=link
```
- **Update a paste with a specific ID**
To update (or add) a paste with a specific ID (or path), you can just specify the ID in the URL.
```bash
curl --data "Hello, World!" http://localhost:8080/?access=
```
- **Update a paste with a password**
To update (or add) a paste with a password, you can specify the password in the URL.
**Only the owner can edit or delete the paste with the password.**
```bash
curl --data "Hello, World!" http://localhost:8080/?access=&password=
```
### Delete
To delete a paste, you can send a DELETE request to the server with the password in the URL.
```bash
curl -X DELETE http://localhost:8080/?access=&password=
```
### Statistics and Management
All data is returned in JSON format. you can use `curl` and pipe it to `python -m json.tools` to get a better view.
- **Statistics**
You can visit the `/stats` path to get the statistics of the paste.
- **List**
You can visit the `/all?access=` path to get a list of all pastes and its statistics.
## Configuration
```toml
[default]
address = "0.0.0.0"
[default.limits]
# only allow 128 KiB of data to be uploaded
"plain/text" = "128 KiB"
[default.pasty]
# the path to the database file
db_path = "berry-pasty.redb"
# the password required to add or delete, set to "" if not needed
access_password = "password"
# the length of the random ID for pastes
random_id_length = 8
# The text displayed on the index page,
# if index_link is specified, it will redirect to the link directly
index_text = "Welcome Berry Pasty!"
index_link = ""
```