feat: use config.json for sentry stuff
This commit is contained in:
parent
56d4c697a1
commit
d0752c8ec7
3 changed files with 30 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
|
config.json
|
||||||
|
|
||||||
# Deployment Unix socket
|
# Deployment Unix socket
|
||||||
*.sock
|
*.sock
|
||||||
|
|
||||||
|
|
8
example_config.json
Normal file
8
example_config.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"SENTRY": {
|
||||||
|
"dsn": "https://public@sentry.example.com/1",
|
||||||
|
"traces_sample_rate": 1.0,
|
||||||
|
"profiles_sample_rate": 1.0,
|
||||||
|
"enable_tracing": true
|
||||||
|
}
|
||||||
|
}
|
20
web.py
20
web.py
|
@ -1,3 +1,5 @@
|
||||||
|
import sentry_sdk
|
||||||
|
import json
|
||||||
from flask import Flask, send_from_directory
|
from flask import Flask, send_from_directory
|
||||||
from partials import partials
|
from partials import partials
|
||||||
from threads import threads
|
from threads import threads
|
||||||
|
@ -5,6 +7,17 @@ from threads import threads
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.register_blueprint(partials, url_prefix='/p')
|
app.register_blueprint(partials, url_prefix='/p')
|
||||||
app.register_blueprint(threads, url_prefix='/threads')
|
app.register_blueprint(threads, url_prefix='/threads')
|
||||||
|
app.config.from_file("config.json", load=json.load)
|
||||||
|
|
||||||
|
# sentry.io error monitoring
|
||||||
|
sentry_config = app.config["SENTRY"]
|
||||||
|
sentry_sdk.init(
|
||||||
|
dsn=sentry_config["dsn"],
|
||||||
|
traces_sample_rate=sentry_config["traces_sample_rate"],
|
||||||
|
profiles_sample_rate=sentry_config["profiles_sample_rate"],
|
||||||
|
enable_tracing=sentry_config["enable_tracing"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def home():
|
def home():
|
||||||
|
@ -17,9 +30,16 @@ def dist(path):
|
||||||
else:
|
else:
|
||||||
return send_from_directory('dist', path + '/index.html')
|
return send_from_directory('dist', path + '/index.html')
|
||||||
|
|
||||||
|
@app.route('/error')
|
||||||
|
def errorthing():
|
||||||
|
1/0
|
||||||
|
return 'hello'
|
||||||
|
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
def not_found(e):
|
def not_found(e):
|
||||||
return send_from_directory('dist', '404.html'), 404
|
return send_from_directory('dist', '404.html'), 404
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0')
|
app.run(host='0.0.0.0')
|
||||||
|
|
Loading…
Reference in a new issue