I just installed Passenger WSGI on my Dreamhost shared hosting to host a flask site. Their documentation is very poor and it took me entirely too long to figure out how to do things like touch tmp/restart.txt, but I finally got up and moving. To teach myself what to do, I am using Miguel Grinberg's Flask tutorial
I had gotten as far as lesson 2, using templates, when I started getting errors any time I used render_template(). This is a bit distressing because it was working for a little bit, then I changed routes.py, whereupon it quit working. Reverting routes.py didn't fix the problem. Unfortunately, Passenger on shared Dreamhost hosting has really crappy (read nonexistent) error logging so I don't know what the problem is beyond
I've looked at all the similar questions on here, and it seems that render_template errors are almost exclusively caused by not having a templates folder in the app directory. This isn't the case here. I tried doing the solution someone with a similar problem tried, and nothing.
Am I missing something really obvious? Here's the directory:
init.py
routes.py
templates/index.html
init.py:
from flask import Flask
app = Flask(__name__)
from public import routes
routes.py
from flask import render_template
from public import app
@app.route('/')
@app.route('/index')
def index():
return render_template('index.html')
index.html (I can't imagine this being the problem, but just in case
<html>
<head>
{% if title %}
<title>{{ title }} - Microblog</title>
{% else %}
<title>Microblog</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
I've tweaked and replaced nearly everything here. Everything works unless I try to use render_template. Is there somehow a problem with the location of the directory? It's exactly where it should be from everything I've read.
EDIT: Solved. I replaced HTML file with a fresh one and it worked. I guess render_template didn't like the indented and tags.
EDIT2: Not solved. It gives me this error seemingly at random for certain HTML files while not giving it for others. Because Dreamhost WSGI doesn't give me any error logging or ability to stack trace I'm completely in the dark here and plowing through Jinja2 questions for answers. There's no pattern, rhyme, or reason to files that give me errors versus ones that don't.