Robyn

Python 2025-08-22

<span class =robyn徽标“ src =”/uploads/20250821/img_68a6e6d8e544730.png“ width =“ 250” style =“ max-width:max-width:100%;>>>>>>>>>>>>

Robyn

Robyn是一个高性能,由社区驱动和创新者友好的网络框架,具有生锈的运行时间。您可以通过检查我们的社区资源来了解更多信息!

图像

资料来源:Techempower第22轮

?安装

您可以简单地使用PIP进行安装。

pip install Robyn

或者,与Conda-Forge

conda install -c conda-forge Robyn

?用法

定义您的API

要定义API,您可以在app.py文件中添加以下代码。

Robyn app = Robyn (__file__) @app.get("/") async def h(request): return "Hello, world!" app.start(port=8080)">
 from Robyn import Robyn

app = Robyn ( __file__ )

@ app . get ( "/" )
async def h ( request ):
    return "Hello, world!"

app . start ( port = 8080 )

?运行代码

只需运行您创建的app.py文件即可。然后,您将可以访问Localhost:8080上的服务器,您可以从其他程序请求。 Robyn提供了几种定制Web服务器的选项。

$ python3 app.py

查看用法

Robyn, a fast async web framework with a rust runtime. options: -h, --help show this help message and exit --processes PROCESSES Choose the number of processes. [Default: 1] --workers WORKERS Choose the number of workers. [Default: 1] --dev Development mode. It restarts the server based on file changes. --log-level LOG_LEVEL Set the log level name --create Create a new project template. --docs Open the Robyn documentation. --open-browser Open the browser on successful start. --version Show the Robyn version. --compile-rust-path COMPILE_RUST_PATH Compile rust files in the given path. --create-rust-file CREATE_RUST_FILE Create a rust file with the given name. --disable-openapi Disable the OpenAPI documentation. --fast Enable the fast mode.">
usage: app.py [-h] [--processes PROCESSES] [--workers WORKERS] [--dev] [--log-level LOG_LEVEL]

Robyn , a fast async web framework with a rust runtime.

options:
  -h, --help            show this help message and exit
  --processes PROCESSES
                        Choose the number of processes. [Default: 1]
  --workers WORKERS     Choose the number of workers. [Default: 1]
  --dev                 Development mode. It restarts the server based on file changes.
  --log-level LOG_LEVEL
                        Set the log level name
  --create              Create a new project template.
  --docs                Open the Robyn documentation.
  --open-browser        Open the browser on successful start.
  --version             Show the Robyn version.
  --compile-rust-path COMPILE_RUST_PATH
                        Compile rust files in the given path.
  --create-rust-file CREATE_RUST_FILE
                        Create a rust file with the given name.
  --disable-openapi     Disable the OpenAPI documentation.
  --fast                Enable the fast mode.

日志级别可以进行调试,信息,警告或错误。

使用-open-browser运行应用程序时,新的浏览器窗口将在应用程序位置打开,例如:

$ python3 app.py --open-browser

添加更多路线

您可以为API添加更多路线。作为示例查看此文件中的路由。

?python版本支持

Robyn与以下Python版本兼容:

Python> = 3.9

建议使用最新版本的Python进行最佳性能。

在开始使用此项目之前,请确保已安装了Python的正确版本。您可以通过在终端中运行以下命令来检查python版本:

python --version

特征

  • 在积极发展!
  • 用锈,顺便说一句
  • 多线程运行时
  • 可扩展
  • 自动openapi生成
  • 一个简单的API
  • 同步和异步函数支持
  • 动态URL路由
  • 多核缩放
  • Websockets!
  • 中间
  • 内置形式数据处理
  • 依赖注入
  • 热重新加载
  • 直接的生锈整合
  • AI代理支持- 内置代理路由和执行
  • ?MCP(模型上下文协议) - 作为服务器连接到AI应用程序
  • 社区首先,真正的福音!

?️如何贡献

?开始

请阅读行为守则,并在向Robyn贡献之前进行贡献。请随时为任何澄清或建议打开问题。

如果您感到好奇。您可以在此处查看更详细的体系结构。

如果您仍然需要帮助才能开始,请随时接触我们的社区不和谐。

在本地发展

先决条件

启动之前,请确保已安装以下内容:

  • python> = 3.9,<= 3.13
  • 锈(最新稳定)
  • C编译器(GCC/Clang)

设置

  • 克隆存储库:

    git clone https://*git**hub.com/sparckles/Robyn.git
    
  • 设置虚拟环境:

    python3 -m venv .venv
    source .venv/bin/activate
    
  • 安装所需的软件包

    pip install pre-commit poetry maturin
    
  • 安装开发依赖性

    poetry install --with dev --with test
    
  • 安装预加入git挂钩

    pre-commit install
    
  • 构建并安装Robyn Rust包装

    maturin develop
    
  • 构建和安装Robyn Rust套件(实验

    maturin develop --cargo-extra-args="--features=io-uring"
    
  • 跑步!

    poetry run test_server
    
  • 运行所有测试

    pytest
    
  • 仅运行集成测试

    pytest integration_tests
    
  • 仅运行单元测试(您不需要为此运行test_server)

    pytest unit_tests
    
  • 测试(有关更多端点

    curl http://local*h*ost*:8080/sync/str
    
  • 提示:一个用于测试更改的衬里!

    maturin develop && poetry run test_server
    
    maturin develop && pytest 
    
  • 提示:对于Io-uring支持,您可以使用以下命令:

    maturin develop --cargo-extra-args="--features=io-uring"
    
  • 提示:要在其他项目中使用本地Robyn版本,您可以使用PIP安装它:

    Robyn -<version>-<python_version>-<platform>.whl">
    pip install -e path/to/ Robyn /target/wheels/ Robyn -<version>-<python_version>-<platform>.whl
    

例如

Robyn -0.63.0-cp312-cp312-macosx_10_15_universal2.whl">
pip install -e /repos/ Robyn /target/wheels/ Robyn -0.63.0-cp312-cp312-macosx_10_15_universal2.whl

故障排除

如果您遇到任何问题,这里有一些常见的修复:

  • 如果您在Maturin开发期间找不到问题(尤其是在Arch Linux上),请安装PIP安装补丁。
  • 如果您遇到生锈编译错误,请确保安装了C编译器:
    • Ubuntu/debian:sudo apt安装构建
    • Fedora:Sudo DNF安装GCC
    • MACOS:安装Xcode命令行工具
    • Windows:安装Visual Studio构建工具

特别感谢

贡献者/支持者

感谢该项目的所有贡献者。没有您所有的支持Robyn将不会是什么。

特别感谢PYO3社区和来自Pyo3-Asyncio的Andrew,其出色的图书馆以及对我的查询的支持。 ?

赞助商

这些赞助商可以帮助我们实现魔术!

星历史

下载源码

通过命令行克隆项目:

git clone https://github.com/sparckles/Robyn.git