Closed dusktreader closed 6 years ago
Been having this problem on 3.0.8. I think it started after I added health check api path, but don't understand exactly why. My currently code for before_request and after_request is:
# Log before request.
@app.before_request
def before():
g.start = time.time()
g.status = 0
if request.endpoint == 'main.health_check':
g.status = 1
pass
else:
logger.debug(f'Received request to endpoint [{request.endpoint}], in blueprint [{request.blueprint}] and security [{request.is_secure}].')
# Useful debugging interceptor to log all endpoint responses
@app.after_request
def after(response):
if g.status == 1:
pass
else:
now = time.time()
duration = round(now - g.start, 2)
duration = time.localtime(duration)
duration = str(duration[4]) + 'm:' + str(duration[5]) + 's'
logger.debug(f'Finished request: [{response.status}], with [{response.data.decode("utf-8")}] and took [{duration}] seconds.')
return response
And my health check route is:
@main.route('/api/health')
def health_check():
return ''
Any ideas on what I might me doing wront? Thanks.
None is the default value of headers. If none are set, the following exception is raised:
This can happen with unhandled exceptions which cause a 500 error, or any response that does not set headers.