小试python 最快的web 框架: japronto

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

japronto性能

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

安装python

mac 环境,

Go:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 标准库读写CSV 文件

CSV 是(Comma Separated Values 逗号分隔值)的英文缩写,通常都是纯文本文件。这里介绍使用python 标准库读写csv 文件的方法。...

python 正确计算大文件md5 值

python 计算文件的md5值很方便,但如果只是简单的把文件都入到内存中,大文件会导致问题,一般采用切片的方式分段计算,下面的几个函数可以很好的解决这个问题。...

Leave a Comment