3 ms·
Rust is not pretty, but it's not that bad: use actix_web::{get, web, App, HttpServer, Responder}; #[get("/hello/{name}")] async fn greet(name: web
by JodieBenitez 3y ago
Rust is not pretty, but it's not that bad:
use actix_web::{get, web, App, HttpServer, Responder};
#[get("/hello/{name}")]
async fn greet(name: web::Path<String>) -> impl Responder {
format!("Hello {name}!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new().service(greet)
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
Of course, anything with brackets can be improved ! ;-)
from sanic import Sanic
from sanic.request import Request
from sanic.response import text, HTTPResponse
app = Sanic("MyHelloWorldApp")
@app.get("/hello/<name>")
async def hello_world(request: Request, name: str) -> HTTPResponse:
return text(f"Hello, {name}")