1
0
Fork 0
mirror of https://github.com/Findus23/cr-search.git synced 2024-09-19 15:23:44 +02:00
cr-search/app.py

32 lines
861 B
Python
Raw Permalink Normal View History

2020-03-07 10:45:39 +01:00
from flask import Flask
2021-07-07 17:27:21 +02:00
from flask_caching import Cache
2020-03-07 10:45:39 +01:00
from playhouse.flask_utils import FlaskDB
from playhouse.pool import PooledPostgresqlDatabase
import config
DATABASE = PooledPostgresqlDatabase(**config.dbauth)
if config.sentryDSN:
2021-01-18 18:39:21 +01:00
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
2021-07-07 17:27:21 +02:00
2020-03-07 10:45:39 +01:00
sentry_sdk.init(
dsn=config.sentryDSN,
integrations=[FlaskIntegration()]
)
2021-07-07 17:27:21 +02:00
if config.production:
2021-10-26 15:30:14 +02:00
CACHE_TYPE = "RedisCache"
2021-07-07 17:27:21 +02:00
CACHE_REDIS_URL = "unix:///run/redis-crsearch/redis-server.sock"
2021-10-26 15:30:14 +02:00
else:
CACHE_TYPE = "NullCache"
2021-07-07 17:27:21 +02:00
2020-03-07 10:45:39 +01:00
# Create a Flask WSGI app and configure it using values from the module.
2021-11-28 19:44:41 +01:00
app = Flask(__name__,static_folder='dist/assets/',static_url_path='/assets/')
2020-03-07 10:45:39 +01:00
app.config.from_object(__name__)
2021-07-07 17:27:21 +02:00
cache = Cache(app)
2020-03-07 10:45:39 +01:00
flask_db = FlaskDB(app)
2021-10-26 21:03:45 +02:00
db: PooledPostgresqlDatabase = flask_db.database