什么是你的文件夹布局的Flask应用程序分为模块? [英] What's your folder layout for a Flask app divided in modules?

查看:103
本文介绍了什么是你的文件夹布局的Flask应用程序分为模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试验来自Django的Flask,我非常喜欢它。我碰到一个问题。我阅读了烧瓶文档和关于大型应用程序或类似的东西的部分,它解释了一个方法来分割你的项目,每个包含自己的静态和模板文件夹以及它自己的视图模块。问题是,我无法找到一种方法,使用SQLAlchemy的Flask扩展模型。它从交互式提示工作来创建表,但是当我在代码中使用它时,它会中断。所以我想知道更多有经验的Flask开发者是如何解决这个问题的。

虽然我还没有准备好宣布,仍然积极致力于提炼样本,您可能会从烧瓶骨架项目中受益我正在发展。我厌倦了重新引导Flask网站,所以我开始了一个完整的示例项目,使用我的最佳做法。我还没有添加任何单元测试,但这应该是足够好的,你开始。请给我反馈或建议,如果你遇到任何。



https://github.com/sean-/flask-skeleton/


I am experimenting with Flask coming from Django and I really like it. There is just one problem that I ran into. I read the flask docs and the part about big applications or something like that and it explains a way to divide your project in packages, each one with its own static and templates folder as well as its own views module. the thing is that I cannot find a way that works to put the models in there using SQLAlchemy with the Flask extension. It works from the interactive prompt to create the tables, but when i use it inside the code it breaks. So I wanted to know how more experienced Flask developers solved this.

解决方案

While I'm not ready to announce because I'm still actively working on refining the samples, you would probably benefit from the flask-skeleton project that I'm developing. I got tired of reinventing the wheel with regards to bootstrapping Flask websites so I started to a complete sample project that uses my best practices. I haven't added any unit tests yet, but this should be good enough for you to start with. Please send me feedback or suggestions if you come across any.

https://github.com/sean-/flask-skeleton/

这篇关于什么是你的文件夹布局的Flask应用程序分为模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆