いくつかのアプリケーション (ブログ、コード、アカウントなど) を使用してシンプルなサイトを実装しています。サイズが大きいため、1 つの python ファイルをアプリに分割することにしました。Flask の基本的な機能以外は、設計図などは使用しません。可能な限りシンプルに保ちたいと考えています。残念ながら、フラスコはまだテンプレートを探しています
/site
|-> main.py
from flask import Flask
app = Flask(__name__)
app.config.from_pyfile('config.py')
# Import all views
from errors.views import * # Errors hasn't its specific prefix
from blog.views import *
from account.views import *
from mysite.views import *
if __name__ == "__main__":
app.run(debug=True)
|-> templates
...................
|->blog
|-> template
|-> _layout.html
|-> index.html
|-> post.html
|-> __init__.py
from main import app
import blog.views
|-> views
from blog import app
from flask import render_template
@app.route("/blog/", defaults={'post_id': None})
@app.route("/blog/<int:post_id>")
def blog_view(post_id):
if post_id:
return "Someday beautiful post will be here with id=%s" % post_id
else:
return "Someday beautiful blog will be here"
@app.route("/blog/tags/")
def tags_view():
pass
..........................