当前位置:网站首页>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/UsersAfter 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/BooksIn 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.1and 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边栏推荐
- 数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
- Guava: use of multiset
- C how to set two columns comboboxcolumn in DataGridView to bind a secondary linkage effect of cascading events
- GPS从入门到放弃(十一)、差分GPS
- Oracle性能分析3:TKPROF简介
- GNN,请你的网络层数再深一点~
- GPS from getting started to giving up (XV), DCB differential code deviation
- [asp.net core] set the format of Web API response data -- formatfilter feature
- Some problems about the use of char[] array assignment through scanf..
- GPS du début à l'abandon (XIII), surveillance autonome de l'intégrité du récepteur (raim)
猜你喜欢

C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果

Reptile practice (V): climbing watercress top250

Numpy download and installation

关于程序员的职业操守,从《匠艺整洁之道》谈起

Adjustable DC power supply based on LM317

GPS from entry to abandonment (XIV), ionospheric delay

What can one line of code do?

功能强大的国产Api管理工具

Shake Sound poussera l'application indépendante de plantation d'herbe "louable", les octets ne peuvent pas oublier le petit livre rouge?

LeetCode:1189. The maximum number of "balloons" -- simple
随机推荐
GPS从入门到放弃(十九)、精密星历(sp3格式)
MySQL removes duplicates according to two fields
JPEG2000 matlab source code implementation
Shell product written examination related
OpenCV300 CMake生成project在项目过程中的问题
Persistence / caching of RDD in spark
GPS from getting started to giving up (XIII), receiver autonomous integrity monitoring (RAIM)
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
GPS from getting started to giving up (16), satellite clock error and satellite ephemeris error
uni-app App端半屏连续扫码
Leetcode topic [array] -118 Yang Hui triangle
[Digital IC manual tearing code] Verilog automatic beverage machine | topic | principle | design | simulation
Happy sound 2[sing.2]
爬虫实战(五):爬豆瓣top250
Adjustable DC power supply based on LM317
string的底层实现
MongoDB(三)——CRUD
GPS从入门到放弃(二十)、天线偏移
1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros