最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【部分解决】优化Flask restful的项目结构

Flask crifan 4622浏览 0评论

之前已经实现了基本的Flask-restful的项目

但是目前的结构是:

更多的代码,暂时只能放在views.py中

希望优化结构

python – Flask-RESTful Project Structure – Stack Overflow

Larger Applications — Flask Documentation (0.10)

Modular Applications with Blueprints — Flask Documentation (0.10)

python – Getting the database connection from application context with Flask-Restful – Stack Overflow

python – How to access api.url_for in big Flask-Restful API – Stack Overflow

-》

Intermediate Usage — Flask-RESTful 0.2.1 documentation

此官网文档,已经给出范例了:

对于稍微复杂一点的项目,项目的结构,可以怎么写,为何这么写。

另外,其中也给出了:

我之前就要去操心的:

用上了:

蓝图Blueprints

的写法。

How To Structure Large Flask Applications | DigitalOcean

Looking For Flask Restful API Design Examples:flask

-》

roundstrial/rounds.py at master · robpearlman/roundstrial · GitHub

Restful API Design using Flask-RESTful (Part 1)

Getting started with RESTful APIs using the Flask microframework for Python

Versioning a Flask-Restful api – Cable Codes

感觉这个结构,更加值得参考。

flask-restful 复杂项目 结构

中高级用法 — Flask-RESTful 0.3.1 documentation

我如何组织 Flask 应用结构 – 技术翻译 – 开源中国社区

->

GitHub – mattupstate/overholt: Example Flask application illustrating some of my common practices

->

https://codeload.github.com/mattupstate/overholt/zip/master

暂时整理成:

还没添加v1,v2之类的版本

也没添加blueprint

但是整理了之前的多个功能代码,放到自己对应的文件中:

有空,再去折腾:

1.添加版本

2.添加蓝图blueprint

转载请注明:在路上 » 【部分解决】优化Flask restful的项目结构

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
89 queries in 0.174 seconds, using 22.16MB memory