mod cached_wattpad; mod components; mod routes; use routes::{index, not_found, story}; use axum::{extract::Extension, routing::get, Router}; use lazy_static::lazy_static; use maud::{html, Markup}; use std::{net::SocketAddr, sync::Arc}; use tokio::runtime::Runtime; use wattpad::Wattpad; lazy_static! { pub static ref TOKIO: Runtime = Runtime::new().unwrap(); pub static ref WATTPAD: Wattpad = TOKIO.block_on(async { Wattpad::new().await.expect("Failed to initialize Wattpad!") }); } fn main() { tracing_subscriber::fmt::init(); lazy_static::initialize(&WATTPAD); let addr: SocketAddr = "127.0.0.1:3000".parse().unwrap(); let app = Router::new() .route("/", get(index::render)) .route("/story", get(story::render)) .fallback(not_found::render); tracing::info!("Listening on {}", addr); TOKIO.block_on(async { let _ = axum::Server::bind(&addr) .serve(app.into_make_service()) .await; }) }