当前位置:网站首页>Support multiple API versions in flask
Support multiple API versions in flask
2022-07-06 22:04:00 【javail】
problem :
I started to design a RESTful webservice with Flask and Python and I'm wondering how one would support multiple API versions in the same project. I started using it Flask and Python To design a RESTful web service , I want to know how to support multiple in the same project API edition .I'm thinking of putting the requested API version in the URL like this: I'm considering the request API The version is in URL in , As shown below :
/myapp/v1/Users
After some time I want to add another endpoint in Version 1.1 of the API and keep everything from v1 which did not change: After a while , I want to API Of 1.1 Add another endpoint in version , And keep v1 Everything unchanged in :
/myapp/v1.1/Users <= Same as in v1/myapp/v1.1/Books
In v2 the "Users"-endpoint is changed: stay v2 in ,“ user ” Endpoint changed :
/myapp/v2/Users <= Changed in v2/myapp/v2/Books <= Same as in v1.1
and so on... wait ...
Looking at this question the easiest way probably would be something like this: see This The simplest way to solve the problem may be like this :
@app.route('/<version>/users')def users(version): # do something return jsonify(response)
But I can imagine that this will get harder to maintain with each new API version. But I can imagine , With every new API edition , This will become more difficult to maintain .Therefore I was wondering if there's any better (= easier to maintain and better structured) way to achieve this with Flask? So I want to know if there is a better (= Easier to maintain and better structured ) Method to use Flask To achieve this goal ?
Solution :
Reference resources : https://stackoom.com/en/question/1wp2X边栏推荐
- Uni app app half screen continuous code scanning
- MPLS experiment
- string的底层实现
- What a new company needs to practice and pay attention to
- Depth first traversal (DFS) and breadth first traversal (BFS)
- Reinforcement learning - learning notes 5 | alphago
- Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
- Earned value management EVM detailed explanation and application, example explanation
- Sparkshuffle process and Mr shuffle process
- GPS from entry to abandonment (XVII), tropospheric delay
猜你喜欢
PostgreSQL 修改数据库用户的密码
Five wars of Chinese Baijiu
用aardio写一个旋转验证码标注小工具
Why rdd/dataset is needed in spark
guava:Collections. The collection created by unmodifiablexxx is not immutable
C how to set two columns comboboxcolumn in DataGridView to bind a secondary linkage effect of cascading events
AI 企业多云存储架构实践 | 深势科技分享
PostgreSQL 安装gis插件 CREATE EXTENSION postgis_topology
The golden age of the U.S. technology industry has ended, and there have been constant lamentations about chip sales and 30000 layoffs
GPS from getting started to giving up (XIII), receiver autonomous integrity monitoring (RAIM)
随机推荐
【10点公开课】:视频质量评价基础与实践
guava:Collections. The collection created by unmodifiablexxx is not immutable
GPS from getting started to giving up (XV), DCB differential code deviation
JPEG2000-Matlab源码实现
11、 Service introduction and port
新入职一家公司需要去实践和注意的内容
The relationship between root and coefficient of quadratic equation with one variable
搜素专题(DFS )
Tiktok will push the independent grass planting app "praiseworthy". Can't bytes forget the little red book?
【MySQL】Online DDL详解
Unity3D学习笔记6——GPU实例化(1)
HDU 2008 数字统计
[Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials
mysql根据两个字段去重
关于char[]数组通过scanf赋值使用上的一些问题。。
Intelligent online customer service system source code Gofly development log - 2 Develop command line applications
GPS from getting started to giving up (XVIII), multipath effect
[daily] win10 system setting computer never sleeps
JPEG2000 matlab source code implementation
Wechat red envelope cover applet source code - background independent version - source code with evaluation points function