From 72a51055d240ec380f6969e62e88a2320624d6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 10 May 2020 22:48:50 +0200 Subject: [PATCH] add a / landing page with a git link --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- src/embed/home.html | 49 +++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 6 ++++++ 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 src/embed/home.html diff --git a/Cargo.lock b/Cargo.lock index 9bfeefb..90d581b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -735,7 +735,7 @@ dependencies = [ [[package]] name = "postit" -version = "0.2.0" +version = "0.2.1" dependencies = [ "anyhow", "bincode", diff --git a/Cargo.toml b/Cargo.toml index f1f22cd..9922f3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "postit" -version = "0.2.0" +version = "0.2.1" authors = ["Ondřej Hruška "] edition = "2018" publish = false diff --git a/README.md b/README.md index 7624dbd..54c8e2a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/embed/home.html b/src/embed/home.html new file mode 100644 index 0000000..6f4a1f5 --- /dev/null +++ b/src/embed/home.html @@ -0,0 +1,49 @@ + + + + Post-it! + + + +

Welcome to Post-it!

+ +

Post-it is a tiny file sharing server for small files with limited lifespan.

+ +

API quickstart

+ +

Submit a file: POST binary body to "/"

+ + + +

Read a file: GET /<file-id>

+ + +

Update a file: PUT to /<file-id>

+ + +

Delete a file: DELETE /<file-id>

+ + +

See the git repository for a more detailed README.

+ +

Source code

+ +

Post-it is written in Rust.

+ +

Get the sources at: https://git.ondrovo.com/MightyPork/postit

+ + + diff --git a/src/main.rs b/src/main.rs index 096547f..04c3d0a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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) + .with_public_cache(86400)); + } + if req.url() == "/favicon.ico" { return decorate_response(Response::from_data("image/vnd.microsoft.icon", FAVICON) .with_public_cache(86400 * 7));