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.
46 lines
1.1 KiB
46 lines
1.1 KiB
mod cached_wattpad;
|
|
mod components;
|
|
mod routes;
|
|
mod web_api;
|
|
|
|
use routes::*;
|
|
|
|
use axum::{routing::get, Router};
|
|
use lazy_static::lazy_static;
|
|
|
|
use std::net::SocketAddr;
|
|
use tokio::runtime::Runtime;
|
|
use wattpad::Wattpad;
|
|
use web_api::get_story;
|
|
|
|
lazy_static! {
|
|
pub static ref TOKIO: Runtime = Runtime::new().unwrap();
|
|
pub static ref WATTPAD: Wattpad = TOKIO.block_on(async {
|
|
let watt = Wattpad::new().await.expect("Failed to initialize Wattpad!");
|
|
watt
|
|
});
|
|
}
|
|
|
|
fn main() {
|
|
tracing_subscriber::fmt::init();
|
|
lazy_static::initialize(&WATTPAD);
|
|
|
|
let addr: SocketAddr = "0.0.0.0:3000".parse().unwrap();
|
|
let app = Router::new()
|
|
.route("/", get(index::render))
|
|
.route("/story", get(story::render))
|
|
.route("/search", get(search::render))
|
|
.route("/history", get(history::render))
|
|
.route("/about", get(about::render))
|
|
.route("/api/getStory", get(get_story))
|
|
.fallback(not_found::render);
|
|
|
|
tracing::info!("Listening on {}", addr);
|
|
|
|
TOKIO.block_on(async {
|
|
let _ = axum::Server::bind(&addr)
|
|
.serve(app.into_make_service())
|
|
.await;
|
|
})
|
|
}
|