add a / landing page with a git link

Ondřej Hruška 3 years ago
parent eb9c2898d0
commit 72a51055d2
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
  2. 2
  3. 4
  4. 49
  5. 6

Cargo.lock generated

@ -735,7 +735,7 @@ dependencies = [
name = "postit"
version = "0.2.0"
version = "0.2.1"
dependencies = [

@ -1,6 +1,6 @@
name = "postit"
version = "0.2.0"
version = "0.2.1"
authors = ["Ondřej Hruška <>"]
edition = "2018"
publish = false

@ -1,6 +1,6 @@
# PostIt file sharing server
# Post-it file sharing server
PostIt is designed to work as a temporary public storage for text (and other)
Post-it is designed to work as a temporary public storage for text (and other)
files uploaded to it by software that need a publicly reachable page without
hosting its own server or even having a public IP.

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<h1>Welcome to Post-it!</h1>
<p>Post-it is a tiny file sharing server for small files with limited lifespan.</p>
<h2>API quickstart</h2>
<h3>Submit a file: POST binary body to "/"</h3>
<li>Accepts <code>X-Expire</code> (secs) and <code>Content-Type</code> headers.
<li>Also accepts an <code>expire</code> URL param.
<li>Returns a secret token in the <code>X-Secret</code> header, and a File ID in response body.
<h3>Read a file: GET /&lt;file-id&gt;</h3>
<li>The remaining lifespan us returned in an <code>X-Expire</code> header (secs).
<h3>Update a file: PUT to /&lt;file-id&gt;</h3>
<li>Accepts the same headers and params as POST.
<li>Body may be left empty to leave it unchanged.
<li>File's lifespan can be extended by setting a new expiration time.
<li>Requires the secret token as an <code>X-Secret</code> header or a <code>secret</code> URL param.
<h3>Delete a file: DELETE /&lt;file-id&gt;</h3>
<li>The secret token is required, like with PUT.
<p>See the git repository for a more detailed README.</p>
<h2>Source code</h2>
<p>Post-it is written in Rust.</p>
<p>Get the sources at: <a href=""></a></p>

@ -35,6 +35,7 @@ const GET_SECRET: &str = "secret";
const FAVICON: &[u8] = include_bytes!("embed/favicon.ico");
const ROBOTS: &[u8] = include_bytes!("embed/robots.txt");
const LANDING_PAGE: &[u8] = include_bytes!("embed/home.html");
/// Post ID (represented as a 16-digit hex string)
type PostId = u64;
@ -97,6 +98,11 @@ fn main() -> anyhow::Result<()> {
info!("{} {}", method, req.raw_url());
if method == "GET" || method == "HEAD" {
if req.url() == "/" {
return decorate_response(Response::from_data("text/html", LANDING_PAGE)
if req.url() == "/favicon.ico" {
return decorate_response(Response::from_data("image/", FAVICON)
.with_public_cache(86400 * 7));