pyList

小试python 最快的web 框架: japronto

japronto 是基于 uvloop、 picohttpparser 性能超赞,下面是官方的性能比较:

japronto性能

下面是第三方性能测试结果 japronto性能

安装python

mac 环境,

brew upgrade python
python 2.7.12_2 -> 3.7.1

Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

安装japronto

官方文档的命令

python3 -m pip install japronto

会有下面的错误:

Collecting japronto
  Could not find a version that satisfies the requirement japronto (from versions: )
No matching distribution found for japronto

翻一下issues 好多人都遇到这样的情况,改用下面的命令完成安装:

pip3 --no-cache install https://github.com/squeaky-pl/japronto/archive/master.zip

示例

from japronto import Application


def hello(request):
    return request.Response(text='Hello world!')


app = Application()
app.router.add_route('/', hello)
app.run(debug=True)

运行:

$ python3 web.py 
Accepting connections on http://0.0.0.0:8080
127.0.0.1 GET /
127.0.0.1 GET /favicon.ico
127.0.0.1 GET /

发现另一个python web 框架也很强悍 vibora https://github.com/vibora-io/vibora 35

框架太多,看个人喜好。

本文标签: python web japronto uvloop
本文网址: https://pylist.com/t/1544873697 (转载注明出处)
如果你有任何建议或疑问可以在下面 留言
发表第一条评论!
验证码图片
相关推荐