base html tamplates & routes

This commit is contained in:
2026-03-28 13:52:02 +03:00
parent cccb1bd694
commit 895a301ace
9 changed files with 252 additions and 10 deletions

25
\ Normal file
View File

@@ -0,0 +1,25 @@
use serde::{Deserialize, Serialize};
use std::fs;
#[derive(Debug, Serialize, Deserialize)]
pub struct Config {
pub host: String,
pub port: u16,
pub debug: bool,
}
impl Config {
// Чтение из YAML
pub fn load(path: &str) -> Result<Self, Box<dyn std::error::Error>> {
let contents = fs::read_to_string(path)?;
let config: Config = serde_yaml::from_str(&contents)?;
Ok(config)
}
// Запись в YAML
pub fn save(&self, path: &str) -> Result<(), Box<dyn std::error::Error>> {
let yaml_string = serde_yaml::to_string(self)?;
fs::write(path, yaml_string)?;
Ok(())
}
}