1

So I have a flask app which is going to run a website on Apache (mod_wsgi). However, it keeps crashing, and the Apache error logs are not recording anything. While there is some documentation here http://flask.pocoo.org/docs/0.12/errorhandling/#logging-to-a-file , I have no idea where to put any of the code. Here is the app code, incidentally. It's crashing due to some permission issues with the method it's calling (needs data from a secure server), but that's not the point.

from model import InputForm
from flask import Flask, render_template, request
from compute import compute

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
            result = compute(form.A.data, form.B.data)
    else:
        result = None

    return render_template('view.html', form=form, result=result)

if __name__ == '__main__':
    app.run(debug=True)

(ignore the indentation issues)

1 Answers1

0

Apache will log anything Flask logs to stdout/stderr. The issue is that Flask itself is not logging anything when it is an internal application error. For a start, temporarily add:

app.debug = True

after app is created in the first place. You need it there as app.run() is not used in mod_wsgi. That will cause errors to show in the browser.

Then go find the Flask config setting to tell it to always log application errors to stdout/stderr. Make sure you remove that setting of app.debug when work that out.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134