小试python 最快的web 框架: japronto

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

japronto性能

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

安装python

mac 环境,

MySQL:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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

官方文档的命令

1
python3 -m pip install japronto

会有下面的错误:

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

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

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

示例

1
2
3
4
5
6
7
8
9
10
from japronto import Application


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


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

运行:

1
2
3
4
5
$ 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

框架太多,看个人喜好。

本文网址: https://pylist.com/topic/162.html 转摘请注明来源

Suggested Topics

python 解析电子书的信息

epub 书是可供人们下载的开放性资源格式的电子图书。epub 文件通常与类似亚马逊Kindle 这样的电子阅读器不兼容。...

给ssdb python 接口提速

SSDB 是个新兴的数据库,其数据库的特点简单,性能高效,有好多python 接口,个人比较后选择一个最理想的,但还有提速空间,这里仅作经验分享。...

Leave a Comment