mirror of
https://github.com/perstarkse/minne.git
synced 2026-03-29 05:41:54 +02:00
init tera and html lsp
This commit is contained in:
@@ -4,6 +4,7 @@ use axum::{
|
||||
Extension, Router,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use tera::Tera;
|
||||
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
||||
use zettle_db::{
|
||||
rabbitmq::{publisher::RabbitMQProducer, RabbitMQConfig},
|
||||
@@ -25,6 +26,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.try_init()
|
||||
.ok();
|
||||
|
||||
let tera = Tera::new("src/server/templates/**/*.html").unwrap();
|
||||
|
||||
// Set up RabbitMQ
|
||||
let config = RabbitMQConfig {
|
||||
amqp_addr: "amqp://localhost".to_string(),
|
||||
@@ -50,7 +53,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.route("/file/:uuid", put(update_file_handler))
|
||||
.route("/file/:uuid", delete(delete_file_handler))
|
||||
.route("/query", post(query_handler))
|
||||
.layer(Extension(db_client));
|
||||
.layer(Extension(db_client))
|
||||
.route(
|
||||
"/hello_world",
|
||||
get(zettle_db::server::routes::hello_world::hello_world_handler),
|
||||
)
|
||||
.layer(Extension(tera));
|
||||
|
||||
tracing::info!("Listening on 0.0.0.0:3000");
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;
|
||||
|
||||
10
src/server/routes/hello_world.rs
Normal file
10
src/server/routes/hello_world.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use axum::Extension;
|
||||
use tera::{Context, Tera};
|
||||
|
||||
use crate::error::ApiError;
|
||||
|
||||
pub async fn hello_world_handler(Extension(tera): Extension<Tera>) -> Result<String, ApiError> {
|
||||
let output = tera.render("hello_world.html", &Context::new()).unwrap();
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod file;
|
||||
pub mod hello_world;
|
||||
pub mod ingress;
|
||||
pub mod query;
|
||||
pub mod queue_length;
|
||||
|
||||
4
src/server/templates/hello_world.html
Normal file
4
src/server/templates/hello_world.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<h1>Hello</h1>
|
||||
<div>Hello</div>
|
||||
<p>HI</p>
|
||||
wowoow
|
||||
Reference in New Issue
Block a user