Initial static serve

demo-mode
Wes Holland 1 year ago
commit 9c6587c367

1
.gitignore vendored

@ -0,0 +1 @@
/target

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="EMPTY_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/inventory-app.iml" filepath="$PROJECT_DIR$/.idea/inventory-app.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

2342
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,19 @@
[package]
name = "inventory-app"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.91"
askama = { version = "0.12.1", features = ["with-axum"] }
axum = "0.7.7"
axum-htmx = "0.6.0"
dotenvy = "0.15.7"
sqlx = "0.8.2"
tokio = { version = "1.41.0", features = ["full", "tracing"] }
tower = { version = "0.5.1", features = ["util"] }
tower-http = { version = "0.6.1", features = ["fs", "trace"] }
tower-sessions = "0.13.0"
tower-sessions-sqlx-store = "0.14.1"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

File diff suppressed because one or more lines are too long

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<link rel="stylesheet" href="css/pico.min.css">
<script src="js/htmx.min.js"></script>
<title>Test Page</title>
</head>
<body>
<main class="container">
<h1>Test Page</h1>
<p>This is a test page</p>
<article>
<h2>Card</h2>
</article>
</main>
</body>
</html>

File diff suppressed because one or more lines are too long

@ -0,0 +1,44 @@
use axum::{
extract::Request, handler::HandlerWithoutStateExt, http::StatusCode, routing::get, Router,
};
use std::net::SocketAddr;
use tower::ServiceExt;
use tower_http::{
services::{ServeDir, ServeFile},
trace::TraceLayer,
};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use anyhow::{Context,Result};
#[tokio::main]
async fn main() -> Result<()>{
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.init();
/*
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
format!("{}=debug,tower_http=debug", env!("CARGO_CRATE_NAME")).into()
}),
)
.with(tracing_subscriber::fmt::layer())
.init();
*/
let router = Router::new()
.route_service("/", ServeFile::new("assets/index.html"))
.nest_service("/js", ServeDir::new("assets/js"))
.nest_service("/css", ServeDir::new("assets/css"));
let address = "0.0.0.0:4206";
let listener = tokio::net::TcpListener::bind(address)
.await
.context("failed to bind")?;
tracing::debug!("listening on {}", address);
axum::serve(listener, router.layer(TraceLayer::new_for_http()))
.await.context("unable to serve")
}
Loading…
Cancel
Save

Powered by TurnKey Linux.