ReactJs & Rust & Actix

 ============================================================================

Rust and ReactJs

Interesting article by Jay Sea:

https://medium.com/@Jayseabee/rust-react-part-i-3a33c3da9ca0  PART 1
https://medium.com/@Jayseabee/rust-react-part-ii-76c2ea60a80d PART 2
   Source: https://github.com/jayseabee/rust-react-julia

Actix crate to listen for GET requests

Rust & React & Actix
  Javascript fetch command calls the julia-image API endpoint vs. React WebSocket API handler
   
============================================================================

Actix and ReactJs

use std::io;
use actix_web::{middleware::Logger, get, post, web, App, HttpResponse, HttpServer, Responder, HttpRequest};
use actix_web_lab::web::spa;

#[actix_web::main]
async fn main() -> io::Result<()> {
    env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
    let bind = ("127.0.0.1", 8081);
    log::info!("staring server at http://{}:{}", &bind.0, &bind.1);

    HttpServer::new(|| {
        App::new()
            .wrap(Logger::default().log_target("@"))
            .route(
                "/api/greet",
                web::to(|| async {
                    "hello world"
                }),
            )
            .service(
                spa()
                    .index_file("./frontend/build/index.html")
                    .static_resources_mount("/static")
                    .static_resources_location("frontend/build/static/")
                    .finish(),
            )
    })
    .workers(1)
    .bind(bind)?
    .run()
    .await
}
   
==========================================================================

Comments

Popular posts from this blog

Upgrading to .NET8 from desktop versions 4.8.X

GHL Chat Bots for Webpage

GHL > Set website so shorter URL address