make the static files directory variable with env
This commit is contained in:
parent
53936258a9
commit
168f7ce09c
|
@ -9,7 +9,7 @@ use axum::{
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::{query, SqlitePool};
|
use sqlx::{query, SqlitePool};
|
||||||
use std::net::SocketAddr;
|
use std::{env, net::SocketAddr};
|
||||||
use tower_http::services::ServeDir;
|
use tower_http::services::ServeDir;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
|
@ -28,10 +28,11 @@ async fn main() {
|
||||||
let db_pool = SqlitePool::connect(DB_URL)
|
let db_pool = SqlitePool::connect(DB_URL)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to connect to the database.");
|
.expect("Failed to connect to the database.");
|
||||||
|
let static_path = env::var("STATIC_PATH").unwrap_or("static".to_string());
|
||||||
|
|
||||||
// build our application with some routes
|
// build our application with some routes
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.nest_service("/static", ServeDir::new("static"))
|
.nest_service("/static", ServeDir::new(static_path))
|
||||||
.route("/", get(register_form))
|
.route("/", get(register_form))
|
||||||
.route("/register/", post(register))
|
.route("/register/", post(register))
|
||||||
.with_state(db_pool);
|
.with_state(db_pool);
|
||||||
|
|
Loading…
Reference in New Issue