当前位置:网站首页>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边栏推荐
- Unity3d Learning Notes 6 - GPU instantiation (1)
- 设置状态栏样式Demo
- guava:Collections. The collection created by unmodifiablexxx is not immutable
- [Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
- Depth first traversal (DFS) and breadth first traversal (BFS)
- mysql根据两个字段去重
- Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
- MySQL - transaction details
- uni-app App端半屏连续扫码
- VIP case introduction and in-depth analysis of brokerage XX system node exceptions
猜你喜欢
【10点公开课】:视频质量评价基础与实践
Basic introduction of figure
Efficiency tool +wps check box shows the solution to the sun problem
Earned value management EVM detailed explanation and application, example explanation
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
uni-app App端半屏连续扫码
Aggregate function with key in spark
功能强大的国产Api管理工具
Adjustable DC power supply based on LM317
Search element topic (DFS)
随机推荐
OpenCV300 CMake生成project在项目过程中的问题
[daily] win10 system setting computer never sleeps
LeetCode:1189. The maximum number of "balloons" -- simple
UNI-Admin基础框架怎么关闭创建超级管理员入口?
Leveldb source code analysis series - main process
MPLS experiment
[asp.net core] set the format of Web API response data -- formatfilter feature
GPS从入门到放弃(十二)、 多普勒定速
What is the RDD operator in spark
Uni app app half screen continuous code scanning
设置状态栏样式Demo
PostgreSQL 修改数据库用户的密码
JPEG2000 matlab source code implementation
抖音將推獨立種草App“可頌”,字節忘不掉小紅書?
小满网络模型&http1-http2 &浏览器缓存
Sequoia China, just raised $9billion
Make menuconfig has a recipe for target 'menuconfig' failed error
十一、服务介绍及端口
Reinforcement learning - learning notes 5 | alphago
Leetcode learning records (starting from the novice village, you can't kill out of the novice Village) ---1