Skip to content

Commit

Permalink
🎨 Example: Use add_template_dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Oct 28, 2018
1 parent fddc9bf commit 646f463
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions examples/flask_todo/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import os

import jinja2
from flask import Flask
from flask_mongoengine import MongoEngine

from flask_mongo_profiler.helpers import add_template_dirs

from .models import TodoTask


Expand Down Expand Up @@ -64,22 +63,14 @@ def create_app(init_profiler=True, init_admin=True):
if init_admin:
setup_flask_admin(app)

add_template_dirs(app)

@app.route('/')
def index():
TodoTask(title='test title').save()
task = TodoTask.objects.first()
return app.response_class(response=task.to_json(), mimetype='application/json')

template_dir = os.path.join(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
'flask_mongo_profiler',
'templates',
)

app.jinja_loader = jinja2.ChoiceLoader(
[app.jinja_loader, jinja2.FileSystemLoader(template_dir)]
)

return app


Expand Down

0 comments on commit 646f463

Please sign in to comment.