Last active
July 28, 2023 21:14
-
-
Save cherryramatisdev/826087f7f1d812fa13428e9f3f067d94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::error::Error; | |
use actix_web::{get, App, HttpResponse, HttpServer}; | |
use leptos::*; | |
const PORT: u16 = 4000; | |
#[get("/")] | |
async fn hello() -> Result<HttpResponse, Box<dyn Error>> { | |
let html = leptos::ssr::render_to_string(move |ctx| { | |
view! { ctx, | |
<head> | |
<script src="https://unpkg.com/htmx.org@1.9.2" integrity="sha384-L6OqL9pRWyyFU3+/bjdSri+iIphTN/bvYyM37tICVyOJkWZLpP2vGn6VUEXgzg6h" crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<h1>Teste</h1> | |
</body> | |
} | |
}); | |
return Ok(HttpResponse::Ok() | |
.content_type("text/html; charset=utf-8") | |
.body(html)); | |
} | |
#[actix_web::main] | |
async fn main() -> std::io::Result<()> { | |
env_logger::init(); | |
log::info!("Starting at {PORT}"); | |
HttpServer::new(|| App::new().service(hello)) | |
.bind(("127.0.0.1", PORT))? | |
.run() | |
.await | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment