- 授权协议: 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);
}
写给大忙人看的C++
【美】Brian Overland(布莱恩.奥弗兰德) / 卢涛、李颖 / 电子工业出版社 / 2015-8 / 109.00
《写给大忙人看的C++》全面介绍了C++语言知识,既提供了学习C++语言最新功能的捷径,也为快速找到特定问题的答案提供了便利。《写给大忙人看的C++》简明地描述了C++核心语言和标准库中几乎所有的函数、对象和运算符,一目了然地显示了语法、结构和重要函数的信息,内容组织形式便于快速查找信息。《写给大忙人看的C++》精选了实用的例子来深入地讲解概念,还提供了富有挑战性的练习及参考答案,便于读者举一反三......一起来看看 《写给大忙人看的C++》 这本书的介绍吧!
