Commit 8181191aeed47706543d65a4c5903aadc3799255
Adding feature
- Flask app will log the errors on to a log file now. Don't have to depend on apache to do it and spend hours on debugging in production.
| | | | 2 | from flask import request | 2 | from flask import request |
---|
3 | from flask import render_template | 3 | from flask import render_template |
---|
4 | from flask import make_response | 4 | from flask import make_response |
---|
| | 5 | from logging import FileHandler |
---|
5 | import json | 6 | import json |
---|
6 | import pymongo | 7 | import pymongo |
---|
7 | import os | 8 | import os |
---|
… | | … | |
---|
61 | return i.split('/')[-1] | 61 | return i.split('/')[-1] |
---|
62 | ls = map(sanitize, ls) | 62 | ls = map(sanitize, ls) |
---|
63 | return render_template('history.html', ls=ls) | 63 | return render_template('history.html', ls=ls) |
---|
| | 64 | |
---|
| | 65 | #Log the errors, don't depend on apache to log it for you. |
---|
| | 66 | fil = FileHandler(os.path.join(os.path.dirname(__file__),'logme'),mode='a') |
---|
| | 67 | fil.setLevel(logging.ERROR) |
---|
| | 68 | app.logger.addHandler(fil) |
---|
64 | | 69 | |
---|
65 | | 70 | |
---|
66 | if __name__ == "__main__": | 71 | if __name__ == "__main__": |
---|