2022-01-08 19:10:27 +00:00
<p align="center">
<img src=".github/banner.svg">
</p>
2021-03-26 22:00:12 +00:00
2021-10-27 23:37:42 +01:00
**paste is a simple web app for writing & sharing code.** It's my own take on conventional pastebin sites like _ pastebin.com _ or _ hastebin _ .
2021-03-26 22:00:12 +00:00
2022-01-18 21:06:12 +00:00
Anyone can use paste! The official/public instance can be accessed using the endpoints listed below, but you can also [host your own ](#host-your-own ) if you like!
2022-09-21 23:21:09 +01:00
2022-01-18 21:06:12 +00:00
##### 1) In a Web Browser
Just go to https://pastes.dev!
##### 2) From the Command Line
2022-09-21 23:21:09 +01:00
You can submit content most easily using [curl ](https://curl.se/docs/manpage.html ).
2022-01-18 21:06:12 +00:00
```shell
# Upload the contents of a file
2022-09-21 23:21:09 +01:00
> curl -T example.txt https://api.pastes.dev/post
# Upload the contents of a file and specify the language
> curl -T example.yml -H "Content-Type: text/yaml" https://api.pastes.dev/post
# Pipe in some output from any command
> echo "Hello world" | curl -T - https://api.pastes.dev/post
2022-01-18 21:06:12 +00:00
```
2022-09-21 23:21:09 +01:00
<details>
<summary>If curl isn't installed on your system, you can also post using <b>netcat</b>.</summary>
```shell
# Pipe in some output from any command
> echo "Hello world" | nc nc.pastes.dev 1337
# Upload the contents of a file
> cat example.txt | nc nc.pastes.dev 1337
```
</details>
<details>
<summary>If you don't want to do so much typing, you can create a shorter <b>alias</b>.</summary>
```bash
# Add this to the end of `~/.bashrc` and run 'source ~/.bashrc'
paste() {
curl -T $1 https://api.pastes.dev/post
}
```
then...
```shell
# Upload the contents of a file
> paste example.txt
# Pipe in some output from any command
> echo "Hello!" | paste -
```
</details>
##### 3) From Code
Send GET/POST/PUT requests to `https://api.pastes.dev/` . More info [below ](#pastesdev-api ).
2022-01-18 21:06:12 +00:00
___
### About
2021-10-27 23:37:42 +01:00
The frontend _ (this repository) _ is written using the React framework. The backend data storage is handled by a separate web service called [bytebin ](https://github.com/lucko/bytebin ).
2021-03-27 17:01:20 +00:00
2022-01-08 19:10:27 +00:00
The user-interface is based on the [Monaco Editor ](https://microsoft.github.io/monaco-editor/ ), the engine behind the popular Visual Studio Code text editor. It's quite simple; it supports syntax highlighting, automatic indentation, many supported languages, themes, zooming in/out, linking to specific lines or sections, and more!
2021-03-27 17:01:20 +00:00
2022-01-18 21:06:12 +00:00
### pastes.dev
2022-01-08 19:10:27 +00:00
2022-01-18 21:06:12 +00:00
I host a public instance at https://pastes.dev. Please feel free to use it to share code/configs/whatever!
2021-03-27 17:01:20 +00:00
2022-01-08 19:10:27 +00:00
Please note that the following (very-non-legally worded) [terms of service ](https://github.com/lucko/bytebin#public-instances ) apply.
If you come across any content which is illegal or infringes on copyright, please [get in touch ](https://lucko.me/contact ) and let me know so I can remove it.
2021-10-27 23:37:42 +01:00
2022-01-08 19:10:27 +00:00
Uploaded content is retained for 90 days then deleted.
2021-09-13 21:28:23 +01:00
2022-01-08 19:10:27 +00:00
### pastes.dev API
2021-03-27 17:01:20 +00:00
2022-01-08 19:10:27 +00:00
* To **read ** content, send a HTTP `GET` request to `https://api.pastes.dev/<key>` .
* Replace `<key>` with the id of the paste.
* The content is returned in the response body.
* The `Content-Type` header is `text/<language>` , where language is the id of the language the paste was saved with.
* To **upload ** content, send a HTTP `POST` request to `https://api.pastes.dev/post` .
* Include the content in the request body.
* Specify the language with the `Content-Type: text/<language>` header, and please provide a `User-Agent` header too.
* The paste "key" is returned in the `Location` header, or in the response body as a JSON object in the format `{"key": "<key>"}` .
2021-03-27 17:01:20 +00:00
2022-01-08 19:10:27 +00:00
The API is powered by the [bytebin ](https://github.com/lucko/bytebin ) service, so more information about how it works can be found there.
2022-01-18 21:06:12 +00:00
___
### Host your own
2021-10-27 23:37:42 +01:00
2022-01-08 19:10:27 +00:00
It's quite simple to host your own version.
2021-03-27 17:01:20 +00:00
```bash
git clone https://github.com/lucko/paste
2022-01-08 19:10:27 +00:00
cd paste
2021-03-27 17:01:20 +00:00
yarn install
2022-01-08 19:10:27 +00:00
# Outputs html/css/js files to /build
2021-09-13 21:28:23 +01:00
yarn build
2021-03-27 17:01:20 +00:00
2022-01-08 19:10:27 +00:00
# Start a webserver for testing/development
2021-09-13 21:28:23 +01:00
yarn start
2021-03-27 17:01:20 +00:00
```
2021-09-13 21:28:23 +01:00
You can then follow the [create-react-app deployment documentation ](https://create-react-app.dev/docs/deployment/ ) for how to host the build output. I personally recommend deploying to the cloud using a service like Netlify instead of hosting on your own webserver.
2021-10-27 23:37:42 +01:00
If you really want to self-host (including the bytebin data storage part), I suggest using Docker:
```bash
git clone https://github.com/lucko/paste
docker compose up -d
```
You should then (hopefully!) be able to access the application at `http://localhost:8080/` .