Skip to content

Commit

Permalink
Init homepage.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkbyers committed Mar 31, 2024
1 parent 7b00ca1 commit 1062281
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 4 deletions.
250 changes: 250 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ reqwest = "0.11.25"
scraper = "0.19.0"
async-openai = "0.19.1"
tiktoken-rs = { version = "0.5.8", features = ["async-openai"] }
tera = "1.19.1"
16 changes: 16 additions & 0 deletions src/routes/index.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use actix_web::{get, HttpResponse};
use tera::{Context, Tera};

#[get("/")]
async fn home() -> HttpResponse {
let tera_context = Context::new();
let rendered = match Tera::one_off(include_str!("../templates/index.html"), &tera_context, true)
{
Ok(rendered) => rendered,
Err(e) => {
eprintln!("Failed to render template: {:?}", e);
return HttpResponse::InternalServerError().finish();
}
};
HttpResponse::Ok().body(rendered)
}
2 changes: 2 additions & 0 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
mod green_recs;
mod health_check;
mod index;
mod scrapes;
mod subscriptions;

pub use green_recs::*;
pub use health_check::*;
pub use index::*;
pub use scrapes::*;
pub use subscriptions::*;
Loading

0 comments on commit 1062281

Please sign in to comment.