Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cherryramatisdev/826087f7f1d812fa13428e9f3f067d94 to your computer and use it in GitHub Desktop.
Save cherryramatisdev/826087f7f1d812fa13428e9f3f067d94 to your computer and use it in GitHub Desktop.
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