An easy-to-use high-performance asynchronous web framework.

Overview

中文 | English

Github Action Test Codecov

Publish PyPi PyPI Downloads

PyPI - Python Version

一个易用的高性能异步 web 框架。

Index.py 文档


Index.py 实现了 ASGI3 接口,并使用 Radix Tree 进行路由查找。是最快的 Python web 框架之一。一切特性都服务于快速开发高性能的 Web 服务。

  • 大量正确的类型注释
  • 灵活且高效的路由系统
  • 可视化 API 接口与在线调试
  • 支持 Server-sent events 与 WebSocket
  • 自带一键部署命令 (基于 uvicorn 与 gunicorn)
  • 可使用任何可用的 ASGI 生态

Install

pip install -U index.py

或者直接从 Github 上安装最新版本(不稳定)

pip install -U git+https://github.com/abersheeran/[email protected]

中国大陆内的用户可从 Gitee 上的镜像仓库拉取

pip install -U git+https://gitee.com/abersheeran/[email protected]
Comments
  • Bump certifi from 2021.10.8 to 2022.12.7

    Bump certifi from 2021.10.8 to 2022.12.7

    Bumps certifi from 2021.10.8 to 2022.12.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • OPTIONS 请求会返回 HTTP 416 错误

    OPTIONS 请求会返回 HTTP 416 错误

    Minimum Example

    from indexpy import Index, Body
    
    app = Index()
    
    @app.router.http.post("/")
    def test(param: str = Body()):
        return dict(error=param)
    
    bug Todo 
    opened by leng-yue 1
  • 使用 BaíZé 重构

    使用 BaíZé 重构

    由于 Starlette 本身现在更像是一个框架而不是一个工具箱,并且 encode 团队似乎没有太多的时间维护这个框架,更多的精力都在 httpx 上。所以直接放弃使用 Starlette,转而使用 BaíZé 进行重构。除部分响应类外,大部分接口仍然可以保持一致。并且相较于 Starlette,BaíZé 有更丰富的功能支持,比如文件响应允许分片、更加完善的响应类泛型。

    Todo 
    opened by abersheeran 1
  • Use `name: Annotated[type, Query(**options)]` replace `name: type = Query(**options)`

    Use `name: Annotated[type, Query(**options)]` replace `name: type = Query(**options)`

    Checklist

    • [X] There are no similar issues or pull requests for this yet.
    • [X] I discussed this idea on the community chat and feedback is positive.

    Is your feature related to a problem? Please describe.

    使用默认值为类型增加描述是妥协的做法。

    Describe the solution you would like.

    async def function(name: name: Annotated[type, Query(**options)]) -> Annotated[Any, PlainTextResponse[200]]:
         return name
    

    Describe alternatives you considered

    Query[type, options]
    

    使用这种方式,编辑器支持不会很好。因为不能传关键词,所以 options 要么是一个充满 None 的序列,要么是一个字典。写起来都不会太舒服。

    opened by abersheeran 0
  • 特例化 `

    特例化 `""` 路由

    在某些情况下需要如下例代码来同时注册 "/user""/user/login" 两个路由。故而仅允许 "" 不以 "/" 开头。

    "/user" // Routes(
        HttpRoute("", ......),
        HttpRoute("/login", ......),
    )
    

    在根上的 "" 跟随浏览器行为,自动转换为 "/" 路由。即 app.router << HttpRoute("", ......) 等价于 app.router << HttpRoute("/", ......)

    Todo 
    opened by abersheeran 0
  • 允许装饰器注册时使用中间件

    允许装饰器注册时使用中间件

    @routes.http("/path", middlewares=[.................])
    def f(): ...
    
    @routes.websocket("/path", middlewares=[.................])
    def f(): ...
    
    Todo 
    opened by abersheeran 0
  • 参数路由与准确路由同时添加,准确路由有可能被覆盖

    参数路由与准确路由同时添加,准确路由有可能被覆盖

    from indexpy.routing.tree import RadixTree
    t = RadixTree()
    
    def donothing():
        pass
    
    def donothing2():
        pass
    
    # 交换下面两个路由的顺序,断言可以通过
    t.append("/app/{hello}/", donothing)
    t.append("/app/hello/", donothing2)
    
    ret = t.search("/app/world/")
    print(ret)   # ({'hello': 'world'}, <function donothing at 0x7f12c94931f0>)
    assert ret[1] == donothing
    
    ret = t.search("/app/hello/")
    print(ret)  # ({'hello': 'hello'}, <function donothing at 0x7f12c94931f0>)
    assert ret[1] == donothing2
    

    期望的行为应该类似于 flask 如下:

    curl xxxx/a1/hello/ ==> hello2
    curl xxxx/a1/world/ ==> hello1
    
    from flask import Flask
    
    app = Flask(__name__)
    
    
    @app.route("/a1/<hello>/")
    def hello1(hello):
        return "hello1"
    
    @app.route("/a1/hello/")
    def hello2():
        return "hello2"
    
    app.run()
    

    另外这里

    https://github.com/abersheeran/index.py/blob/e895d06ec26bdb4196f919229417b424f5e066a2/indexpy/routing/tree.py#L57-L66

    检查路由冲突的地方

    第 60 行的 if (node.re_pattern == re_pattern) != (node.characters == param_name): 会不会有 re_pattern 不同, 而 characters == param_name 相同的情况?(这一块没太看懂)

    opened by kele1997 0
  • 使 FileRoutes 支持函数

    使 FileRoutes 支持函数

    使用类固然使局部代码更加紧凑,但是也牺牲了使用的便捷性。遂决定增加使用的函数的注册方式,原有注册方式保持不变。

    *.py 文件中未寻找到 HTTP 对象,则寻找如下名称的函数作为对应 HTTP 请求方法的处理函数:"get", "post", "put", "patch", "delete", "head", "options", "trace"。这意味着使用时不需要继承 indexpy.HttpView,直接定义一个名为 get 的异步函数即可处理请求。

    在内部代码里,使用 MultimethodRoutes 同等方式,合并多个函数到一个类中。

    Todo 
    opened by abersheeran 0
Owner
Aber
明道若昧 进道若退 夷道若颣
Aber
FastAPI framework, high performance, easy to learn, fast to code, ready for production

FastAPI framework, high performance, easy to learn, fast to code, ready for production Documentation: https://fastapi.tiangolo.com Source Code: https:

Sebastián Ramírez 53k Jan 2, 2023
Fast, asynchronous and elegant Python web framework.

Warning: This project is being completely re-written. If you're curious about the progress, reach me on Slack. Vibora is a fast, asynchronous and eleg

vibora.io 5.7k Jan 8, 2023
cirrina is an opinionated asynchronous web framework based on aiohttp

cirrina cirrina is an opinionated asynchronous web framework based on aiohttp. Features: HTTP Server Websocket Server JSON RPC Server Shared sessions

André Roth 32 Mar 5, 2022
Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.

Tornado Web Server Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed. By using non-blocking ne

null 20.9k Jan 1, 2023
Asynchronous HTTP client/server framework for asyncio and Python

Async http client/server framework Key Features Supports both client and server side of HTTP protocol. Supports both client and server Web-Sockets out

aio-libs 13.2k Jan 5, 2023
Goblet is an easy-to-use framework that enables developers to quickly spin up fully featured REST APIs with python on GCP

GOBLET Goblet is a framework for writing serverless rest apis in python in google cloud. It allows you to quickly create and deploy python apis backed

Austen 78 Dec 27, 2022
web.py is a web framework for python that is as simple as it is powerful.

web.py is a web framework for Python that is as simple as it is powerful. Visit http://webpy.org/ for more information. The latest stable release 0.62

null 5.8k Dec 30, 2022
Asita is a web application framework for python based on express-js framework.

Asita is a web application framework for python. It is designed to be easy to use and be more easy for javascript users to use python frameworks because it is based on express-js framework.

Mattéo 4 Nov 16, 2021
A very simple asynchronous wrapper that allows you to get access to the Oracle database in asyncio programs.

cx_Oracle_async A very simple asynchronous wrapper that allows you to get access to the Oracle database in asyncio programs. Easy to use , buy may not

null 36 Dec 21, 2022
The no-nonsense, minimalist REST and app backend framework for Python developers, with a focus on reliability, correctness, and performance at scale.

The Falcon Web Framework Falcon is a reliable, high-performance Python web framework for building large-scale app backends and microservices. It encou

Falconry 9k Jan 1, 2023
A high-level framework for building GitHub applications in Python.

A high-level framework for building GitHub applications in Python. Core Features Async Proper ratelimit handling Handles interactions for you (

Vish M 3 Apr 12, 2022
Fully featured framework for fast, easy and documented API development with Flask

Flask RestPlus IMPORTANT NOTICE: This project has been forked to Flask-RESTX and will be maintained by by the python-restx organization. Flask-RESTPlu

Axel H. 2.7k Jan 4, 2023
Fully featured framework for fast, easy and documented API development with Flask

Flask RestPlus IMPORTANT NOTICE: This project has been forked to Flask-RESTX and will be maintained by by the python-restx organization. Flask-RESTPlu

Axel H. 2.5k Feb 17, 2021
TinyAPI - 🔹 A fast & easy and lightweight WSGI Framework for Python

TinyAPI - ?? A fast & easy and lightweight WSGI Framework for Python

xArty 3 Apr 8, 2022
Async Python 3.6+ web server/framework | Build fast. Run fast.

Sanic | Build fast. Run fast. Build Docs Package Support Stats Sanic is a Python 3.6+ web server and web framework that's written to go fast. It allow

Sanic Community Organization 16.7k Jan 8, 2023
The Web framework for perfectionists with deadlines.

Django Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out. All docu

Django 67.9k Dec 29, 2022
The Python micro framework for building web applications.

Flask Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to co

The Pallets Projects 61.5k Jan 6, 2023
Async Python 3.6+ web server/framework | Build fast. Run fast.

Sanic | Build fast. Run fast. Build Docs Package Support Stats Sanic is a Python 3.6+ web server and web framework that's written to go fast. It allow

Sanic Community Organization 16.7k Dec 28, 2022
bottle.py is a fast and simple micro-framework for python web-applications.

Bottle: Python Web Framework Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module a

Bottle Micro Web Framework 7.8k Dec 31, 2022