kochab/examples/serve_dir.rs

19 lines
494 B
Rust

use std::path::PathBuf;
use anyhow::*;
use log::LevelFilter;
use kochab::{Server, GEMINI_PORT};
#[tokio::main]
async fn main() -> Result<()> {
env_logger::builder()
.filter_module("kochab", LevelFilter::Debug)
.init();
Server::bind(("localhost", GEMINI_PORT))
.add_route("/", PathBuf::from("public")) // Serve directory listings & file contents
.add_route("/about", PathBuf::from("README.md")) // Serve a single file
.serve()
.await
}