- 授权协议: BSD
- 开发语言: Rust
- 操作系统: 跨平台
- 软件首页: https://github.com/fengsp/pencil
- 软件文档: http://fengsp.github.io/pencil/
软件介绍
Pencil Framework 是一个 Rust 的微框架,其灵感来自于 Flask。
一个简单应用:
extern crate pencil;
use pencil::{Pencil, Request, Response, PencilResult};
fn hello(_: &mut Request) -> PencilResult {
Ok(Response::from("Hello World!"))
}
fn main() {
let mut app = Pencil::new("/web/hello");
app.get("/", "hello", hello);
app.run("127.0.0.1:5000");
}路由:
fn user(r: &mut Request) -> PencilResult {
let user_id = r.view_args.get("user_id").unwrap();
Ok(format!("user {}", user_id).into())
}
fn main() {
// app here
app.get("/user/<int:user_id>", "user", user);
}JSON 处理:
use std::collections::BTreeMap;
use pencil::jsonify;
fn app_info(_: &mut Request) -> PencilResult {
let mut d = BTreeMap::new();
d.insert("name", "hello");
d.insert("version", "0.1.0");
return jsonify(&d);
}
fn main() {
// app here
app.get("/info", "app_info", app_info);
}错误处理:
use pencil::HTTPError;
fn page_not_found(_: HTTPError) -> PencilResult {
let mut response = Response::from("Customized 404 :)");
response.status_code = 404;
Ok(response)
}
fn main() {
// app here
app.httperrorhandler(404, page_not_found);
}
网站转换率优化之道
[美] Khalid Saleh、[美] Ayat Shukairy / 顾 毅 / 人民邮电出版社 / 2012-4 / 45.00元
内容简介: 怎样才能将访问者转化为顾客? 本书提供了一些切实可行的建议,比如如何说服访问者作出购买决定,如何避免用户因信息过量或导航繁琐而离开网站等。不论你是在设计或营销大型电子商务网站,还是在管理中小型在线业务,都可以从本书学会怎样使用市场营销原则、设计方法、可用性原则和分析数据来持续提升网站的转换率。 作者帮助过众多公司吸引在线顾客,有着丰富的实战经验,在书中细致讨论了从访问......一起来看看 《网站转换率优化之道》 这本书的介绍吧!
