python - Flask per-application template folder -


i implementing simple site couple of applications (like blog, code, account, etc). decided split 1 python file apps due large size. not using blueprints or else except basic functionality of flask - i'd keep simple possible. unfortunately, flask still looking templates in

/site |-> main.py      flask import flask       app = flask(__name__)      app.config.from_pyfile('config.py')       # import views      errors.views import *  # errors hasn't specific prefix      blog.views import *      account.views import *      mysite.views import *       if __name__ == "__main__":          app.run(debug=true) |-> templates ................... |->blog   |-> template     |-> _layout.html     |-> index.html     |-> post.html   |-> __init__.py      main import app      import blog.views   |-> views      blog import app      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 here id=%s" % post_id          else:              return "someday beautiful blog here"       @app.route("/blog/tags/")      def tags_view():          pass      .......................... 

lets have 2 blueprints blog , account. can divide individual apps(blueprints) of blog , account follows:

myproject/     __init__.py     templates/         base.html         404.html          blog/             template.html             index.html             post.html          account/             index.html             account1.html     blog/         __init__.py         views.py     account/         __init__.py         views.py 

in blog/views.py, can render templates like:

@blog.route('/') def blog_index():     return render_template('blog/index.html')  @account.route('/') def account_index():     return render_template('account/index.html') 

..and on


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -