Rust Language HelloWorld Web Edition
The following article is worth reading carefully:
Http://arthurtw.github.io/2014/12/21/rust-anti-sloppy-programming-language.html
Iron is a web framework that is built on top of hyper, and hyper is an HTTP library written entirely in rust. Therefore, iron is equivalent to Tomcat/jetty to Java,
Cowboy to Erlang. The following is the use of iron write a webserver, very simple, when the user in the browser address bar access to http://localhost:3000,
Browser return: HelloWorld.
Very simple, just 3 steps:
1) Install rust. Refer to my article series: http://blog.csdn.net/ubuntu64fan/article/details/47863935
2) Create a HelloWorld project. Refer to my article series: http://blog.csdn.net/ubuntu64fan/article/details/48370617
3) Modify the HELLO_WORLD/CARGO.TOML to add the following content:
[Dependencies]iron = "*"
To modify hello_world/src/main.rs, the full contents are as follows:
extern Crate Iron;use Iron::p relude::*; use IRON::STATUS;FN main () { fn Hello_world (_: &mut Request), Ironres ult<response> { ok (response::with ((Status::ok, "Hello world!")) } Iron::new (Hello_world). HTTP ("localhost:3000"). Unwrap (); println! ("on 3000");}
Then run the compile command under hello_world/:
# Cargo build# Cargo Run
Running ' Target/debug/hello_world '
Open a browser, view: localhost:3000
Hello world!
Rust several terms:
Cargo:rust language Construction tools, very image, truck, put things in the meaning of loading.
Crate: A Java-equivalent jar package, A/C + + so. Wicker box, a variety of wicker boxes loaded in the lorry.
Compiler for Rustc:rust languages.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Rust Language HelloWorld Web Edition