0

I converted some of my apps to application factory. After converting the apps the templates folder can't be found.

/newsite
   wsgi.py
   config.py
   /application
      __init__.py
      /routes
        my_routes.py
        /templates
             index.html
      /templates
         index.html

In my __init__.py

....
from .routes import my_routes
app.register_blueprint(my_routes.route_bp)

In routes/my_routes.py

route_bp = Blueprint('route_bp',__name__,template_folder='static')
@route_bp('/home',methods=['GET'])
    return render_template('index.html')

Render templates fails. The app does not know where the templates for is. I added both template folders and added inth.html into both. How can I know where flask thinks the template folder is located.? I have printed current_app.templates_folder it only prints templates but how do I find the absolute path of the templates folder. So I can put my templates in the correct path. I thought the path should be in the applications folder however that doesn't seem to be correct.

user3525290
  • 1,557
  • 2
  • 20
  • 47
  • Setting `app.config['EXPLAIN_TEMPLATE_LOADING']=True` may help. This should print some useful info in the server console when you reload a page. – v25 May 08 '20 at 00:15
  • After adding the `app.config` it still prints `templates` – user3525290 May 08 '20 at 10:42
  • Setting `template_folder='static'` on the blueprint sounds wrong. If removing that doesn't sort it, maybe also see: [this answer](https://stackoverflow.com/a/8198325/2052575) – v25 May 08 '20 at 11:13
  • Thanks to everyone. But it was a complete programming error I needed `render_template('index.html')` I had `render_template(index.html)` – user3525290 May 08 '20 at 11:14

0 Answers0