小试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

给ssdb python 接口提速

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

python 半角全角的相互转换

全角与半角在中文输入法里经常要接触到,后台在处理用户输入数据时需要对半角全角的相互转换。下面是python 实现的半角全角的相互转换功能。...

3行 Python 代码解简单的一元一次方程

一元一次方程:只含有一个未知数(即“元”),并且未知数的最高次数为1(即“次”)的整式方程叫做一元一次方程(英文名:`linear equation with one unknown`)。...

Leave a Comment