当前位置:网站首页>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边栏推荐
- Make menuconfig has a recipe for target 'menuconfig' failed error
- C language: comprehensive application of if, def and ifndef
- Michael smashed the minority milk sign
- HDU 4912 paths on the tree (lca+)
- [go][reprint]vscode run a HelloWorld example after configuring go
- Leveldb source code analysis series - main process
- Method return value considerations
- GPS从入门到放弃(十六)、卫星时钟误差和卫星星历误差
- Basic introduction of figure
- MariaDb数据库管理系统的学习(一)安装示意图
猜你喜欢

PostgreSQL modifies the password of the database user

PostgreSQL 修改数据库用户的密码

UNI-Admin基础框架怎么关闭创建超级管理员入口?

Numpy download and installation

LeetCode学习记录(从新手村出发之杀不出新手村)----1

JPEG2000-Matlab源码实现

Bat script learning (I)

make menuconfig出现recipe for target ‘menuconfig‘ failed错误

Sparkshuffle process and Mr shuffle process

功能强大的国产Api管理工具
随机推荐
Explain ESM module and commonjs module in simple terms
新入职一家公司需要去实践和注意的内容
20 large visual screens that are highly praised by the boss, with source code templates!
Bat script learning (I)
GPS from entry to abandonment (XIV), ionospheric delay
Set status bar style demo
Intelligent online customer service system source code Gofly development log - 2 Develop command line applications
语谱图怎么看
GNN, please deepen your network layer~
HDU 4912 paths on the tree (lca+)
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
1D convolution detail
[asp.net core] set the format of Web API response data -- formatfilter feature
Guava: three ways to create immutablexxx objects
GPS du début à l'abandon (XIII), surveillance autonome de l'intégrité du récepteur (raim)
Oracle Performance Analysis 3: introduction to tkprof
Oracle性能分析3:TKPROF简介
GNN,请你的网络层数再深一点~
GPS从入门到放弃(十五)、DCB差分码偏差
MongoDB(三)——CRUD