2018-12-10 15:05:02 +00:00
|
|
|
from os import getenv
|
|
|
|
|
|
|
|
from sentry_sdk import init as sentry_init
|
|
|
|
from sentry_sdk.integrations.sanic import SanicIntegration
|
|
|
|
|
|
|
|
from sanic import Sanic
|
|
|
|
from sanic.response import json
|
|
|
|
|
|
|
|
sentry_init(
|
|
|
|
dsn=getenv("SENTRY_DSN"),
|
|
|
|
integrations=[SanicIntegration()],
|
|
|
|
)
|
|
|
|
|
2021-12-23 22:30:27 +00:00
|
|
|
app = Sanic("Example")
|
2018-12-10 15:05:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
# noinspection PyUnusedLocal
|
|
|
|
@app.route("/working")
|
|
|
|
async def working_path(request):
|
2021-12-23 22:30:27 +00:00
|
|
|
return json({"response": "Working API Response"})
|
2018-12-10 15:05:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
# noinspection PyUnusedLocal
|
|
|
|
@app.route("/raise-error")
|
|
|
|
async def raise_error(request):
|
|
|
|
raise Exception("Testing Sentry Integration")
|
|
|
|
|
|
|
|
|
2021-12-23 22:30:27 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
app.run(host="0.0.0.0", port=getenv("PORT", 8080))
|