diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2021-08-21 18:28:30 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2021-08-21 18:28:30 -0400 |
| commit | 47dca324a446bf088164a8e27404c2b8db89ccf5 (patch) | |
| tree | cd6407bd09ee5acc027fc69a51d98156a6ab7e9a /templates/index.tpl | |
| parent | d25b274356451623382d18d2e0e190f407dbcf9f (diff) | |
| download | paste-47dca324a446bf088164a8e27404c2b8db89ccf5.tar.gz paste-47dca324a446bf088164a8e27404c2b8db89ccf5.tar.xz | |
Turn it into a simple rough draft of an API driven pastebin
Diffstat (limited to 'templates/index.tpl')
| -rw-r--r-- | templates/index.tpl | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/templates/index.tpl b/templates/index.tpl new file mode 100644 index 0000000..10ede35 --- /dev/null +++ b/templates/index.tpl @@ -0,0 +1,60 @@ +{{template "base" .}} + +{{define "title"}}Simple Pastebin{{end}} + +{{define "content"}} +<h1>Simple pastebin</h1> + +This is a simple pastebin that effectively only has API access. + +Usernames are hard coded into the configuration file. The format is simple: + +<pre><code>Users: + username: + Password: "password" +</code></pre> + +If there are any non empty `Password` fields they will be replaced with the +hash on first run. + + +Run a request to `/login` to receieve a token: + +<pre><code>$ curl -D /dev/fd/2 -d '{"Username": "mitch", "Password": "secret"}' localhost:6130/login +HTTP/1.1 200 OK +Authorization: Bearer eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjk2MjY4ODMsInN1YiI6Im1pdGNoIn0.8t5IU8WCVWwMozWyufGqFFmKF1mggLI7V8U1tX-u3yllTalbQRgG2PrxPQeVU9pAM6fuapmydXXZYGpehezqDw +Content-Type: application/json +Date: Sat, 21 Aug 2021 22:08:03 GMT +Content-Length: 180 + +{"token":"eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjk2MjY4ODMsInN1YiI6Im1pdGNoIn0.8t5IU8WCVWwMozWyufGqFFmKF1mggLI7V8U1tX-u3yllTalbQRgG2PrxPQeVU9pAM6fuapmydXXZYGpehezqDw"} +$ +</code></pre> + +To add a paste use `/new`: + +<pre><code>$ export token=eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Mjk2MjY4ODMsInN1YiI6Im1pdGNoIn0.8t5IU8WCVWwMozWyufGqFFmKF1mggLI7V8U1tX-u3yllTalbQRgG2PrxPQeVU9pAM6fuapmydXXZYGpehezqDw +$ curl -D /dev/fd/2 -X POST -d ' + { + "Title": "My title!", + "Tags": {"code": null, "c": null}, + "Content": "This is my test content.\n\n\n" + }' -H "Authorization: Bearer $token" localhost:6130/new +HTTP/1.1 200 OK +Content-Type: application/json +Date: Sat, 21 Aug 2021 22:20:53 GMT +Content-Length: 46 + +{"id":"YAv-lFYh9xpnP6ZZ0-Hu_w","status":"ok"} +$ +</code></pre> + +Viewing the json is pretty easy: + +<pre><code>$ curl localhost:6130/view/json/YAv-lFYh9xpnP6ZZ0-Hu_w +{"Id":"YAv-lFYh9xpnP6ZZ0-Hu_w","Title":"My +title!","Tags":{"c":{},"code":{}},"Content":"This is my test content.\n\n\n"} +$ +</code></pre> + +{{end}} |
