Compare commits
2 Commits
8c64c5dbe3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ac59f65f2 | |||
| 4a25c377c4 |
13
assets/css/ip.css
Normal file
13
assets/css/ip.css
Normal file
@@ -0,0 +1,13 @@
|
||||
.ip {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.ip h1 {
|
||||
font-family: 'Indie Flower', cursive;
|
||||
font-size: 60px;
|
||||
text-align: center;
|
||||
color: var(--clr-primary-a60);
|
||||
}
|
||||
@@ -16,6 +16,7 @@ use middleware::MimeType;
|
||||
use pages::{
|
||||
files::file,
|
||||
index,
|
||||
ip::ip,
|
||||
music::music,
|
||||
projects::{project, projects},
|
||||
};
|
||||
@@ -111,7 +112,8 @@ async fn main() {
|
||||
.service(index)
|
||||
.service(projects)
|
||||
.service(project)
|
||||
.service(music),
|
||||
.service(music)
|
||||
.service(ip),
|
||||
)
|
||||
})
|
||||
.bind(bind_address)
|
||||
@@ -119,7 +121,7 @@ async fn main() {
|
||||
match server.run().await {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
eprintln!("An error occurred: {e}");
|
||||
println!("An error occurred: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
src/pages/ip.rs
Normal file
34
src/pages/ip.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use crate::html::elements::{Heading, Link};
|
||||
use crate::html::layouts::Division;
|
||||
use crate::html::pages::BasePage;
|
||||
use crate::html::{Render, boxed_vec};
|
||||
use actix_web::HttpRequest;
|
||||
use actix_web::{Responder, get};
|
||||
|
||||
#[get("/ip")]
|
||||
async fn ip(request: HttpRequest) -> impl Responder {
|
||||
let info = request.connection_info();
|
||||
let ip = info.realip_remote_addr();
|
||||
|
||||
let text = Heading::builder()
|
||||
.text(format!(
|
||||
"Your IP address is {}<br>Don't ask how I know.",
|
||||
ip.unwrap_or("?")
|
||||
))
|
||||
.build();
|
||||
let div = Division::builder()
|
||||
.classes(vec!["ip"])
|
||||
.elements(boxed_vec![text])
|
||||
.build();
|
||||
|
||||
let css = Link::builder()
|
||||
.rel("stylesheet")
|
||||
.href("/static/css/ip.css")
|
||||
.build();
|
||||
BasePage::builder()
|
||||
.title("Your IP address")
|
||||
.head(boxed_vec![css])
|
||||
.body(boxed_vec![div])
|
||||
.build()
|
||||
.render()
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
pub(crate) mod files;
|
||||
pub(crate) mod ip;
|
||||
pub(crate) mod music;
|
||||
pub(crate) mod projects;
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ use sqlx::query_as;
|
||||
async fn music(state: Data<AppState>) -> impl Responder {
|
||||
let featured_title = HeadingBuilder::new()
|
||||
.level(1)
|
||||
.text("The song I've been listening to the most recently is \"Hot\" by Avril Lavigne.")
|
||||
.text("The song I've been listening to the most recently is \"Shiawase - VIP\" by Dion Timmer.")
|
||||
.build();
|
||||
let featured_iframe = IframeBuilder::new()
|
||||
.src("https://www.youtube.com/embed/fzb75m8NuMQ")
|
||||
.src("https://www.youtube.com/embed/suisIF4hwyw")
|
||||
.build();
|
||||
let featured = DivisionBuilder::new()
|
||||
.classes(vec!["featured"])
|
||||
|
||||
Reference in New Issue
Block a user