Compare commits
4 Commits
89c3ee2cfc
...
5e90f3436a
| Author | SHA1 | Date |
|---|---|---|
|
|
5e90f3436a | |
|
|
856482ce17 | |
|
|
70842b1db2 | |
|
|
02af71212e |
|
|
@ -0,0 +1,2 @@
|
|||
[env]
|
||||
STATIC_FILE_PATH = { value = "static", relative = true }
|
||||
|
|
@ -0,0 +1 @@
|
|||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
|
|
@ -1,3 +1,9 @@
|
|||
|
||||
# Emacs
|
||||
*~
|
||||
\#*#
|
||||
.#*
|
||||
|
||||
# ---> Rust
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "localhub"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1", features = ["rt-multi-thread"]}
|
||||
axum = "0.7"
|
||||
askama = "0.12"
|
||||
askama_axum = "0.4"
|
||||
tower-http = { version = "0.5", features = ["fs"] }
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
use std::env;
|
||||
use askama::Template;
|
||||
use axum::{routing::get, Router};
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let app = Router::new()
|
||||
.route("/", get(root))
|
||||
.nest_service("/static", ServeDir::new(env::var("STATIC_FILE_PATH")?));
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
|
||||
axum::serve(listener, app).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
struct IndexTemplate<'a> {
|
||||
title: &'a str,
|
||||
}
|
||||
|
||||
async fn root<'a>() -> IndexTemplate<'a> {
|
||||
IndexTemplate { title: "LocalHub" }
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>{{title}}</title>
|
||||
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="static/favicon-32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="static/favicon-16.png">
|
||||
<!-- For Google and Android -->
|
||||
<link rel="icon" type="image/png" sizes="48x48" href="static/favicon-48.png">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="static/favicon-192.png">
|
||||
<!-- For iPad -->
|
||||
<link rel="apple-touch-icon" type="image/png" sizes="167x167" href="static/favicon-167.png">
|
||||
<!-- For iPhone -->
|
||||
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="static/favicon-180.png">
|
||||
</head>
|
||||
<body>
|
||||
It still works!
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue