diff --git a/Pipfile b/Pipfile index f99b6a7..f4aee4e 100644 --- a/Pipfile +++ b/Pipfile @@ -4,6 +4,9 @@ verify_ssl = true [packages] gunicorn = "*" -Flask = "*" decorator = "*" brotlipy = "*" +Flask = "*" + +[packages.raven] +extras = [ "flask",] diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..f527bc2 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,62 @@ +{ + "_meta": { + "hash": { + "sha256": "53116ad7b310b08706e5c73063a39d06acc144ee22cf0dc9783758e69556b76a" + }, + "requires": {}, + "sources": [ + { + "url": "https://pypi.python.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "Flask": { + "version": "==0.12" + }, + "Jinja2": { + "version": "==2.9.5" + }, + "MarkupSafe": { + "version": "==1.0" + }, + "Werkzeug": { + "version": "==0.12.1" + }, + "blinker": { + "version": "==1.4" + }, + "brotlipy": { + "version": "==0.6.0" + }, + "cffi": { + "version": "==1.9.1" + }, + "click": { + "version": "==6.7" + }, + "contextlib2": { + "version": "==0.5.4" + }, + "decorator": { + "version": "==4.0.11" + }, + "enum34": { + "version": "==1.1.6" + }, + "gunicorn": { + "version": "==19.7.0" + }, + "itsdangerous": { + "version": "==0.24" + }, + "pycparser": { + "version": "==2.17" + }, + "raven": { + "version": "==6.0.0" + } + }, + "develop": {} +} \ No newline at end of file diff --git a/app.json b/app.json index 7fa1493..34049e5 100644 --- a/app.json +++ b/app.json @@ -4,5 +4,6 @@ "repository": "https://github.com/Runscope/httpbin", "website": "https://httpbin.org", "logo": "https://s3.amazonaws.com/f.cl.ly/items/333Y191Z2C0G2J3m3Y0b/httpbin.svg", - "keywords": ["http", "rest", "API", "testing", "integration", "python", "flask"] + "keywords": ["http", "rest", "API", "testing", "integration", "python", "flask"], + "addons": "sentry" } diff --git a/httpbin/core.py b/httpbin/core.py index 3f83c39..6f24474 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -16,10 +16,11 @@ import uuid import argparse from flask import Flask, Response, request, render_template, redirect, jsonify as flask_jsonify, make_response, url_for +from six.moves import range as xrange from werkzeug.datastructures import WWWAuthenticate, MultiDict from werkzeug.http import http_date from werkzeug.wrappers import BaseResponse -from six.moves import range as xrange +from raven.contrib.flask import Sentry from . import filters from .helpers import get_headers, status_code, get_dict, get_request_range, check_basic_auth, check_digest_auth, secure_cookie, H, ROBOT_TXT, ANGRY_ASCII @@ -50,6 +51,12 @@ BaseResponse.autocorrect_location_header = False tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates') app = Flask(__name__, template_folder=tmpl_dir) +app.debug = bool(os.environ.get('DEBUG')) + +# Send app errors to Sentry. +if 'SENTRY_DSN' in os.environ: + sentry = Sentry(app, dsn=os.environ('SENTRY_DSN')) + # Set up Bugsnag exception tracking, if desired. To use Bugsnag, install the # Bugsnag Python client with the command "pip install bugsnag", and set the