please make the servehtml function missing here: #![allow(warnings)] use base64::encode;…
- User
please make the serve_html function missing here:
#![allow(warnings)] use base64::encode; use notify::Watcher; use std::fs::File; use std::io::{self, Read, Write}; use std::path::PathBuf;
use clap::Parser; use pulldown_cmark::{html, Event, Options, Parser as MdParser}; use tokio::sync::{broadcast, RwLock}; use warp::Filter;
use std::sync::Arc;
#[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { #[arg(value_name = "FILE")] file: Option,
code#[arg(short, long)] static_mode: bool,}
#[tokio::main] async fn main() -> io::Result<()> { // Parse command-line arguments let args = Args::parse();
codeif args.static_mode { run_static_mode(&args)?; } else { run_server_mode(&args).await?; } Ok(())}
fn run_static_mode(args: &Args) -> io::Result<()> { // Read Markdown content let (file_name, markdown_input) = match &args.file { Some(file_path) => { let mut file = File::open(&file_path).unwrap_or_else(|err| { eprintln!("Error opening file {}: {}", file_path.display(), err); std::process::exit(1); }); let mut content = String::new(); file.read_to_string(&mut content)?; ( file_path.file_name().unwrap().to_string_lossy().to_string(), content, ) } None => { // Read from stdin if no file is provided let mut content = String::new(); io::stdin().read_to_string(&mut content)?; (String::from("New file"), content) } };
code - Assistant