Skip to content
This repository was archived by the owner on Oct 27, 2023. It is now read-only.

dasedb/json_interface_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

使用Flask开发一个JSON Web服务

安装依赖

pip install Flask
pip install pytest
pip install coverage

启动flask web服务器

python app.py

终端显示,默认在5000端口监听

* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

测试服务

可能使用任何web客户端和浏览器测试服务。推荐使用Postman.

curl -L 'http://127.0.0.1:5000/cal/add/10/30'

显示JSON格式响应

{"ok":true,"result":40}

Test and Coverage

利用pytestcoverage测试和评估代码

执行单元测试

pytest

覆盖率测试:

coverage run -m pytest

报告覆盖率:

coverage report

显示覆盖率报告:

Name Stmts Miss Branch BrPart Cover
---------------------------------------------------------
calculate_init_.py 6 0 0 0 100%
calculate\cal.py 20 0 8 0 100%
---------------------------------------------------------
TOTAL 26 0 8 0 100%

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages