-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
72 lines (57 loc) · 2.01 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding:utf-8 -*-
import os
import locale
import logging
from flask import render_template
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
from sentry_sdk.integrations.redis import RedisIntegration
from werkzeug.serving import WSGIRequestHandler
from main import create_app, make_celery
locale.setlocale(locale.LC_TIME, 'pt_PT.utf8')
# Create and config Flask app
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
app.config['APPLICATION_ROOT'] = '/arquivopt'
# Create and config Celery
app.config.update(
CELERY_BROKER_URL='redis://localhost:6379',
CELERY_RESULT_BACKEND='redis://localhost:6379'
)
celery = make_celery(app)
app.celery = celery
sentry_sdk.init(
dsn="https://[email protected]/5630277",
integrations=[FlaskIntegration(), RedisIntegration()],
traces_sample_rate=1.0
)
WSGIRequestHandler.protocol_version = "HTTP/1.1"
@app.context_processor
def add_session_config():
"""Add current_app.permanent_session_lifetime converted to milliseconds
to context. The config variable PERMANENT_SESSION_LIFETIME is not
used because it could be either a timedelta object or an integer
representing seconds.
"""
return {
'PERMANENT_SESSION_LIFETIME_MS': (
app.permanent_session_lifetime.seconds * 60000),
}
@app.errorhandler(404)
def page_not_found(error):
app.logger.error('Page not found:')
return render_template('pages/404.html'), 404
#@app.errorhandler(500)
#def page_internal_server_error(error):
# app.logger.error('Internal server error:')
# return render_template('pages/500.html'), 500
@app.errorhandler(Exception)
def page_globalerror(error):
#app.logger.error('Global error handler:')
if app.config['DEBUG']:
app.logger.error(error, exc_info=True)
else:
raise error
return render_template('pages/500.html'), 500
if __name__ == '__main__':
app.run(host="0.0.0.0", port="5000")
# app.run(host="0.0.0.0", port="5000", ssl_context='adhoc')