2 个版本
使用旧的 Rust 2015
0.4.4 | 2018 年 5 月 17 日 |
---|---|
0.4.3 | 2018 年 5 月 16 日 |
#859 in HTTP 服务器
225KB
2.5K SLoC
#chilli (A Sharp Pencil fork)
受 Flask 启发的 Rust 微型框架。
extern crate chilli;
use chilli::{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");
}
一个简单的指南: https://github.com/golddranks/sharp_pencil https://fengsp.github.io/blog/2016/3/introducing-pencil/
如果你觉得有任何问题,欢迎反馈或提交 pull request。
lib.rs
:
Pencil 是一个受 Flask 启发的 Rust 微型框架。
安装
此 crate 被称为 chilli
,您可以通过 cargo 依赖它。
[dependencies]
chilli = "*"
快速入门
对 chilli 的简要介绍。
最小应用程序
一个最小的 chilli 应用程序看起来像这样
extern crate chilli;
use chilli::Pencil;
use chilli::{Request, PencilResult, Response};
use chilli::method::Get;
fn hello(_: &mut Request) -> PencilResult {
Ok(Response::from("Hello World!"))
}
fn main() {
let mut app = Pencil::new("/web/hello");
app.route("/", &[Get], "hello", hello);
app.run("127.0.0.1:5000");
}
依赖项
~16MB
~329K SLoC