An ergonomic and elegant framework for creating Gemini servers and SCGI apps without needless bloat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.1 KiB

use std::path::PathBuf;
2 years ago
use anyhow::*;
use log::LevelFilter;
use kochab::Server;
2 years ago
/// Serving some static content from the filesystem is easy with Kochab
/// This example serves from the `./public` directory on the base route, and adds a
/// special one-page bind to `/about` that always serves ``
/// Note, use this module with a little bit of caution. The directory serving feature is
/// currently unfinished, and the API is subject to change dramatically in future updates.
/// It should be secure, but you may need to do some refactoring in coming updates.
2 years ago
async fn main() -> Result<()> {
// We set up logging so we can see what's happening. This isn't technically required,
// and you can use a simpler solution (like env_logger::init()) during production
.filter_module("kochab", LevelFilter::Debug)
.add_route("/", PathBuf::from("public")) // Serve directory listings & file contents
.add_route("/about", PathBuf::from("")) // Serve a single file
2 years ago