2个版本
| 0.1.1 | 2020年7月12日 |
|---|---|
| 0.1.0 | 2020年7月12日 |
#47 in #pokemon
33KB
530 行
Poke-speare
REST API,给定一个宝可梦名称,以莎士比亚风格返回其描述。
宝可梦描述来自 PokéAPI,并使用 Shakespeare translator 转换。
用法
您可以使用 poke-speare 作为Web服务器和Rust库
Web服务器
$ curl https://:5000/pokemon/charizard
{
"name": "charizard",
"description": "Charizard flies 'round the sky in search of powerful opponents."
}
库
let shakespeare_api_token = None;
let pokemon_descr = poke_speare::get_description("charizard", shakespeare_api_token).await;
println!("description: {}", pokemon_descr);
安装
Cargo
- 按照此指南安装rust工具链以安装cargo。
- 运行
cargo install poke-speare
Docker
$ docker pull marcoieni/poke-speare
运行
Cargo
确保 ~/.cargo/bin 已添加到您的 PATH。
$ poke-speare
Docker
$ docker run -p 5000:5000 marcoieni/poke-speare
设置
您可以通过设置环境变量来更改设置。例如
$ RUST_LOG=debug POKE_SPEARE_PORT=5001 poke-speare
以下列出所有环境变量及其默认值
RUST_LOG:error. 其他可能的值:infoPOKE_SPEARE_HOST:"127.0.0.1"POKE_SPEARE_PORT:5000POKE_SPEARE_SHAKESPEARE_TOKEN:"". Shakespeare translator 每日有60个API调用限制,每小时分配5个调用。如果您有FunTranslations API密钥,请设置环境变量POKE_SPEARE_SHAKESPEARE_TOKEN。
许可证
根据您的选择,许可如下
- Apache License,版本2.0 (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证 (LICENSE-MIT 或 https://open-source.org.cn/licenses/MIT)
。
贡献
除非您明确声明,否则根据Apache-2.0许可证定义的,您有意提交以包含在作品中的任何贡献,应按上述方式双重许可,不得添加任何额外的条款或条件。
致谢
- GitHub动作来自 LukeMathWalker。
依赖项
~24–36MB
~649K SLoC