feat: frontend routes (just the index html file for now)
This commit is contained in:
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -1645,6 +1645,7 @@ dependencies = [
|
||||
"serde_with",
|
||||
"strum",
|
||||
"tokio",
|
||||
"tower-http 0.7.1",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"typed-builder",
|
||||
@@ -2127,7 +2128,7 @@ dependencies = [
|
||||
"tokio-rustls",
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tower-http",
|
||||
"tower-http 0.6.11",
|
||||
"tower-service",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
@@ -2860,6 +2861,21 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-http"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"bytes",
|
||||
"http",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-layer"
|
||||
version = "0.3.3"
|
||||
|
||||
@@ -28,6 +28,7 @@ serde_json = "1.0.151"
|
||||
serde_with = "3.24.0"
|
||||
strum = { version = "0.28.0", features = ["derive"] }
|
||||
tokio = { version = "1.53.1", features = ["macros", "rt-multi-thread"] }
|
||||
tower-http = { version = "0.7.1", features = ["cors"] }
|
||||
tracing = "0.1.44"
|
||||
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
|
||||
typed-builder = "0.23.2"
|
||||
|
||||
11
src/server/frontend.rs
Normal file
11
src/server/frontend.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use axum::response::Html;
|
||||
use axum_extra::routing::TypedPath;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/")]
|
||||
pub struct IndexPath;
|
||||
|
||||
pub async fn spa(_: IndexPath) -> Html<&'static str> {
|
||||
Html(include_str!("index.html"))
|
||||
}
|
||||
@@ -6,11 +6,13 @@ use rand::Rng;
|
||||
use rand::RngExt;
|
||||
use secrecy::SecretString;
|
||||
use std::sync::Arc;
|
||||
use tower_http::cors::CorsLayer;
|
||||
use typed_builder::TypedBuilder;
|
||||
use url::Url;
|
||||
|
||||
mod chat;
|
||||
mod decisions;
|
||||
mod frontend;
|
||||
mod embeddings;
|
||||
mod models;
|
||||
mod system_one;
|
||||
@@ -46,6 +48,8 @@ pub fn create_router() -> Router<AppState> {
|
||||
.typed_post(embeddings::create_embeddings)
|
||||
.typed_post(system_one::create_system_one)
|
||||
.typed_get(models::list_models)
|
||||
.typed_get(frontend::spa)
|
||||
.layer(CorsLayer::new())
|
||||
}
|
||||
|
||||
pub fn create_app(state: AppState) -> Router<()> {
|
||||
|
||||
Reference in New Issue
Block a user